Problem launching backup script from cron

Andrew Glen-Young aglenyoung at gmail.com
Thu Oct 18 09:41:55 UTC 2007


On 17/10/2007, Steve Waage <waage at macalester.edu> wrote:
> Hello,
>     I've installed the following job in root's crontab file ...
>
> # m h  dom mon dow   command
> 20 17 * * *  /usr/bin/find / -depth -xdev|/bin/cpio -o>/backup/`date
> +%A`.cpio
>
>    ...and right on time my  /var/log/syslog file contains the following
> entry...
>
> Oct 17 17:20:01 content /USR/SBIN/CRON[5921]: (root) CMD (/usr/bin/find
> / -depth -xdev|/bin/cpio -ov>/backup/`date +)
>
>     ... but the job never runs.  I've been running the same command from
> the shell.  Any tips on why it won't run
> from cron?
>

It's the percent sign (%) which you need to escape.

man crontab(5):

"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 crontab file.  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. There is  no way to split a single command
line onto multiple lines, ala the shellâs trailing "\"."

- A.




More information about the ubuntu-users mailing list