Differences between revisions 4 and 8 (spanning 4 versions)
Revision 4 as of 2008-11-22 16:42:31
Size: 561
Editor: GreyCat
Comment: formatting change
Revision 8 as of 2014-04-29 02:10:28
Size: 596
Editor: ormaaj
Comment: It's slightly easier to remember how backslashes work with single-quotes.
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:

In many versions of {{{crontab}}}, the percent sign (%) is treated specially, and therefore must be escaped with backslashes.
In many versions of {{{crontab}}}, the percent sign (%) is treated specially, and therefore must be escaped with backslashes:
Line 7: Line 6:
0 0 * * * some command > /var/log/mylog.`date +\%Y\%m\%d` 0 0 * * * some_user some_command >"/var/log/mylog.$(date '+\%Y\%m\%d')"
Line 11: Line 10:

----
CategoryShell

Why does my crontab job fail? 0 0 * * * some command > /var/log/mylog.`date +%Y%m%d`

In many versions of crontab, the percent sign (%) is treated specially, and therefore must be escaped with backslashes:

0 0 * * * some_user some_command >"/var/log/mylog.$(date '+\%Y\%m\%d')"

See your system's manual (crontab(5) or crontab(1)) for details. Note: on systems which split the crontab manual into two parts, you may have to type man 5 crontab or man -s 5 crontab to read the part you need.


CategoryShell

BashFAQ/043 (last edited 2014-04-29 02:10:28 by ormaaj)