[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: proper escaping sequence in crontab?
> I want my daily/weekly cron files to spool to disk as email is disabled.
> So I tried the following command but it's getting chopped off right
> after the + (plus) sign. Why is this happening and how can I fix it? If
> I put any character between the + and % it works but that character
> shows up in the filename which is not what I want.
> /bin/sh /etc/daily 2>&1 > /root/daily.`date "+%y%m%d"`
> which cron says becomes the following when executed:
> ( /bin/sh /etc/daily 2>&1 > /root/daily.`date "+)
It appears you did not read the crontab(5) manpage:
The ``sixth'' field (the rest of the line) specifies the
command to be run. The entire command portion of the
line, up to a newline or % character, will be executed by
/bin/sh or by the shell specified in the SHELL variable of
the cronfile. 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.
That said, there is a bug which prevents \% from being properly
un-escaped later on when the command is executed. I have just fixed
this bug in cron, and things now work better.