Home › Forums › OS X Server and Client Discussion › Questions and Answers › mv print.log date.log › Move and rename on a daily basis
Rogier,
You can do this! You’ll need to write a shell script to handle the rename/move bit, though. I recommend picking up a copy of [i:5306a32a42]Using csh & tcsh[/i:5306a32a42] (O’Reilly) if you aren’t familiar with the shell. Or, you could write the script in Perl or Python, too. Heck, you could probably write a compiled AppleScript to do it, too.
Regardless, you’ll want the script to build a string with the current date?this will probably be easier to do in Perl or Python?and append it to a string representing the file name.
Execute the mv shell command, giving it the old and new file names. That will move the file from the old to the new name. You may need to ‘touch’ the plain file so that the log daemon will pick up the name change, or send SIGHUP to the daemon process.
Once you have the script created and working, you can add it to a cron job under your account. If you don’t already have a crontab, then create a file called “mycron.in” containing:[code:1:5306a32a42]#
Logroller cron tab
MAILTO=your_user_name
#
@daily * * * * path/to/script[/code:1:5306a32a42]
then feed it into cron with crontab -u your_user_name mycron.in
If you already have a crontab, you can append the @daily line by using crontab -e.
Comments are closed