Tuesday, March 25, 2008

Log file with date and timestamp of cron job

Currently, I am redirecting the output of cron job to a log file. But, I want the log file to have date and timestamp, so that cron creates a new file each time it runs.

So, I tried following logics. But, they did not worked.

This is what I had done:

LOGIC 1:
15 * * * * /home/glg/bin/clc.sh >> /home/glg/logs/cronlogs/clc_`date+%Y.%m.%d.%H.%M.%S`.log 2>&1

The CRON itself did not ran.

LOGIC 2:
CLCLOG = /home/glg/logs/cronlogs/clc_`date+%Y.%m.%d.%H.%M.%S`.log

15 * * * * /home/glg/bin/clc.sh >> $CLCLOG

The cron ran but created a log file by name - "clc_`date+%Y.%m.%d.%H.%M.%S`.log", instead of clc_2008.03.24.23.15.00.log.

Do anyone know what can be the solution for this?

Thanks in advance for your help!!

No comments:

Post a Comment