-   Linux - Newbie (
-   -   cron and the "+" (

dizowned 08-21-2008 12:35 PM

cron and the "+"
Basically I have a cron job that creates a file and I want to append the date to the file with specific formatting. I'm trying to use the data command to do this and whenever cron executes and comes across the "+" for the Format string part of the date command it just stops reading and that becomes the command - so ie the cron log has in it the command being executed as (..... cmd ouput_'date +) when it should be
(..... cmd output 'date +%F%m...'). Is there something weird with cron and the "+"?

colucix 08-21-2008 12:38 PM

No. There is an issue with the % sign. It has a special meaning in crontab. Here is an excerpt from man 5 crontab:

Percent-signs (%) in the command, unless escaped with backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input.
You have to escape the % sign and the trick is done.

dizowned 08-21-2008 12:49 PM

nvm, just figured out you have to escape the %.

Doh, beat me too it - thanks for the quick reply though.

All times are GMT -5. The time now is 03:25 AM.