i have a scheduled task running for every 30 mins in ubuntu. i'm writing the log to a file called sh_tsk.log and using >>
so that it doesn't overwrite. But what i want is to separate logs using dates. i.e today's log should be in a file named after today's date and tomorrow's log should be in a file named after tomorrow's date. i know i can use touch
keyword to create a file. But what i don't know is how do i create the file using current date?
views:
134answers:
2thank you.. got it. i'm using like this though date +%d%m%Y :P
tony_le_montana
2009-11-23 11:39:08
with %Y%m%d you'll get log files sorted in a proper way.
pingw33n
2009-11-23 11:44:34
+1
A:
$> touch `date +%F`.log
You should be getting the file as 2009-11-23.log
. Now you can use >> to output to this log file.
peakit
2009-11-23 11:45:01