Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 09-08-2012, 12:31 PM   #1
Black September
LQ Newbie
Registered: Sep 2012
Distribution: Ubuntu, OpenBSD, Mac OS X
Posts: 2

Rep: Reputation: Disabled
logrotate and date variables

Hi all.

OS: 12.04.1 LTS (GNU/Linux 3.2.0-30-generic x86_64)

I have some questions about logrotate and using it together with some custom scripts that i have added to the crontab.

As far as i have understood, its possible to add custom logs that will be managed by logrotate.

The scripts im using create their own directory structure
`-- 2012
`-- September
|-- 2012.Sep.08.logFile1.log
|-- 2012.Sep.08.logFile2.log
`-- 2012.Sep.08.logFile3.log

The path to where the logs are stored and the name of the log files themselves will change each month/day.

I have been searching for a way to pass variables to logrotate, making it understand the dates thats used by the script and make it look for them in the correct path.

Im thinking something down the lines of telling logrotate to rotate the file in:

From the man pages of logrotate i found the 'dateformat' and 'dateext' option, but as far as i can understand its not what im looking for here as its not only the name of the log files thats changing, but also the directories in which they are stored.

Is this even possible or will i have to change the scripts to be more logrotate "friendly"?

My apologies if this has been answered before, but i could not find anything that could solve it.
Old 09-09-2012, 08:24 AM   #2
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594
What you're telling us is the application or (r)syslog(-ng) rotates logs itself based on a "%Y/%B/%Y.%b.%d.*whatever.log" output template. So you don't need logrotate. If you want compression of "old" log files, for example of the previous month, you could achieve that with a simple script, a cron job, selecting your path based on a date setting like '/bin/date +"%Y/%B/" --date="1 month ago";' would output "2012/August/".
1 members found this post helpful.
Old 09-09-2012, 08:47 AM   #3
Black September
LQ Newbie
Registered: Sep 2012
Distribution: Ubuntu, OpenBSD, Mac OS X
Posts: 2

Original Poster
Rep: Reputation: Disabled
Hi unSpawn

Appreciate you taking the time and replying to me.

Eventually i created a standalone script that sorted this, much like you describe.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving files from one directory to another based on 2 date variables dsfreddie Linux - Newbie 4 06-28-2012 11:14 AM
[SOLVED] logrotate or logrotate.conf; problems with sftp slufoot80 Linux - Server 1 11-05-2011 07:50 AM
logrotate with date in filename ptp Linux - Newbie 1 04-14-2011 10:55 AM
logrotate not rotating files with date extension ajayan Linux - Newbie 1 10-25-2010 06:08 PM
Bash Script: parse active process stderr, strip, dump into variables, use variables TimeFade Programming 1 02-13-2010 06:09 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:20 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration