Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

filename with Timestamp in Cronoutput

Status
Not open for further replies.
Jun 21, 2006
6
US
Hi
I am using Linux Redhat and I have a cronjob scheduled. I would like to redirect the output to a filename with data and time . I tried the following syntax but it didn't work

10 * * * * * list_files.sh > /tmp/list_files`date`.log

My requirement is the listfiles script should spool the output to list_files_dd-mon-yyyy_hh24:mi:ss.log.

Thanks for you help

Upilli Appan
 
man date
a starting point:
/tmp/list_files_`date +%d-%b-%Y_%T`.log

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
one more hint:
man crontab

Have a look on how to treat a % sign in a cron command;
this might be an annoying problem otherwise!
 
You may have to adapt PHV's suggestion to use

[tt]/tmp/list_files_`date +\%d-\%b-\%Y_\%T`.log[/tt]

As % has special meaning, at least in some versions of cron (e.g. Solaris).

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top