1827599 Members
2759 Online
109966 Solutions
New Discussion

output file via cron

 
SOLVED
Go to solution
Ruediger Noack
Valued Contributor

output file via cron

I want to get a output file from my hourly cron command named ..
The crontab entry looks like
0 * * * * command >> .`date +%y%m%d`
But it doesn't work correctly. All I get is a file named "." (without date suffix).
Is it possible to create a filename like described without a script?

Thanks for replies
Ruediger
3 REPLIES 3
Ian Dennison_1
Honored Contributor

Re: output file via cron

Did you try the date command on the command line before putting it in cron?

date +'%d%m%y'

Note the individual quotes around the format string.

Share and Enjoy! Ian
Building a dumber user
John Palmer
Honored Contributor
Solution

Re: output file via cron

Hi,

cron interprets % characters as newlines - see man crontab.

Try escaping the % characters i.e.

0 * * * * command >> .`date +\%y\%m\%d`

Regards,
John
Ruediger Noack
Valued Contributor

Re: output file via cron

Hi John,

if someone can read (or type "man") it is a large advantage sometimes...

Thanks
Ruediger