LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   cron and the "+" (https://www.linuxquestions.org/questions/linux-newbie-8/cron-and-the-664369/)

dizowned 08-21-2008 11:35 AM

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 11:38 AM

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

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 11:49 AM

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

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


All times are GMT -5. The time now is 07:52 AM.