• Register
First time here? Checkout the FAQ!
Welcome to Find4Answers.com

Where you can Ask Questions, Find Answers Or Receive Answers from other members of the community And Share in Social networking sites like facebook, linkedin, twitter.
3cx phone system assignment writing service bandar bola best waikiki restaurants boiler business car car insurance quotes car insurance quotes car insurance quotes car lease deals car leasing uk chwilówka przez internet zapewne company convey convey law complaints convey law reviews convey law service conveylaw cosmetic dentist csr classics hack csr classics hack csr classics hack data data recovery maidenhead deals design development double glazing leeds electrician electrician manchester electricians emergency farm filmy bez limitu filmy online finlock finlock solutions general genral golf holidays spain graduate jobs in london graduate jobs london heap how to jump higher how to jump higher how to jump higher infrared sauna infrared sauna saunas inline skating java judi bola law law firm in leeds lease leasing led lights led bulbs leeds legal smoke life insurance quotes log london manchester mercedes lease deals mercedes leasing mezzanine movies museums and art nikogo szybka chwilówka none none none ny male revue outsource link building paid search agency performance car hire personal personal injury lawyer porcelain veneers ramię szybkie chwilówki recovery restaurant seo seo agencies seo company seo company london seo las vegas seo services services sky diamond seo solutions steel synchronization szybka chwilówka przykład szybka chwilówka żaden szybkie chwilówki lekko temp cover car insurance temp cover car insurance temp cover car insurance thread tymczasem chwilówki przez internet upvc windows manchester viagra kamagra videos vinyl flooring suppliers wait web development company window repairs london windows zobaczyć szybka chwilówka

Sending cron output to a file with a timestamp in its name

0 votes

I have a crontab like this on a LAMP setup:

0 0 * * * /some/path/to/a/file.php > $HOME/cron.log 2>&1

This writes the output of the file to cron.log. However, when it runs again, it overwrites whatever was previously in the file.

How can I get cron to output to a file with a timestamp in its filename?

An example filename would be something like this: 2010-02-26-000000-cron.log

I don't really care about the format, as long as it has a timestamp of some kind.

Thanks in advance.


asked Aug 10, 2012 in Shell Script by anonymous

1 Answer

0 votes


0 0 * * * /some/path/to/a/file.php > $HOME/`date +\%Y\%m\%d\%H\%M\%S`-cron.log 2>&1

Play around with the date format, if you like; just be sure to escape any % like \%, as above.


answered Aug 10, 2012 by sarada Hot Users (2,340 points)

Related questions

0 votes
0 answers 50 views
0 votes
1 answer 685 views
0 votes
1 answer 114 views
0 votes
1 answer 482 views
0 votes
1 answer 138 views