Click to See Complete Forum and Search --> : Shell Scripting


Laslo7
11-02-2001, 12:05 PM
I have a file that is created daily via logrotate, access.log, logrotate names the file access.log.1,access.log.2,access.log.3 and so on. I would like to write a shell script to run as a cron job to rename the access.log to (todaysdate)access.log, ie, 11022001access.log. How would one go about doing this. Commands I figure I will need, date and mv are there any others?
Any pointers or hints to get me started, as this will be the second shell script I have ever written.


AJ

paulb
11-02-2001, 12:43 PM
Try this link.

Here (http://www.linuxdoc.org/LDP/abs/html/index.html)

danrees
11-02-2001, 12:43 PM
I may be mistaken (probably), but I think logrotate can do this for you. Have you checked the man page?

dante_d
11-03-2001, 08:12 AM
datestamp=$(date +%Y%m%d)
mv access.log ${datestamp}access.log

or even more simply:

mv access.log `date +%Y%m%d`access.log