[ale] cron vs. command line

Joe Steele joe at madewell.com
Sat Oct 26 15:43:17 EDT 2002



You need to escape every '%' with a backslash, otherwise cron will treat
them specially.  The first % marks the end of the command.  Everything
after it is fed as standard input to the command.  Any subsequent %s are
converted to newlines.  see man 5 crontab. 

You probably will also find that ${HOSTNAME} is undefined.  Try
$(hostname) instead.  Other than that, it should work fine. 

--Joe


On Sat, 26 Oct 2002, Denny Chambers wrote:

> Hi All,
> 
> 	I have put together a simple backup script to back up my home directory 
> on my development box. I have it scheduled to run in a cron job. The 
> problem is that what I tested on the command line, does not work in the 
> cron job. I am sure I am missing something simple here.
> 
> Here is the crontab entry:
> 5 0 * * *       $HOME/bin/backup.sh >> 
> $HOME/logs/backuplog-${HOSTNAME}-$(date +%m-%d-%y).log 2>&1
> 
> 
> here is the error i get in my inbox:
> Subject: Cron <dchambers at honeybee> $HOME/bin/backup.sh >> 
> $HOME/logs/backuplog-${HOSTNAME}-$(date +
> 
> /bin/sh: -c: line 1: unexpected EOF while looking for matching `)'
> /bin/sh: -c: line 2: syntax error: unexpected end of file
> 
> 
> is there some thing wrong with this:$(date +%m-%d-%y)
> 
> or is there a limit on the command length in a crontab file????
> 
> Thanks,
> Denny
> 
> 
> ---
> This message has been sent through the ALE general discussion list.
> See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
> sent to listmaster at ale dot org.
> 



---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.






More information about the Ale mailing list