[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Cron not working



On Sun, 12 Jul 2015 14:22:22 -0400, Haines Brown wrote:

> On Sun, Jul 12, 2015 at 05:11:21PM +0000, Dan Purgert wrote:
>> On Sun, 12 Jul 2015 13:02:43 -0400, Haines Brown wrote:
>> 
>> > This may be a FAQ, but it has me stumped. I try to do a weekly backup
>> > with this, but nothing happens, and there is nothing in syslog:
>> > 
>> >   # crontab -l 0 4 * * 0 /home/haines/scripts/backup
>> > 
>> > I can run the script manually with # /home/haines/scripts/backup.
>> > 
>> > Cron daemon is running:
>> > 
>> >   $ ps -ef | grep cron | grep -v grep root      8972     1  0 12:37 ?
>> >       00:00:00 cron
>> 
>> It's most likely that your script is using some environment variable
>> that's not (inherently) present to the cron daemon;  or a pathing issue
>> (e.g. ~/Documents is different to you than it is to the [root] Cron
>> job).
> 
> Interesting suggestion. The backup script does the following:
> 
>   a) mounts the external drive b) sleeps a bit c) removes oldest backup
>   with a find command d) constructs a backup directory using mkdir e)
>   does a backup with the find command f) writes to a log using printf g)
>   unmounts the backup drive
> 
> I don't see how any of this draws on an environment variable. A possible
> exception is $(date) and `date +%Y.%m.%d`. I provide full paths in the
> script to avoid the other problem.
> 
> The backup script is an executable owned by user.

Perhaps "environment variable" was the wrong phrase.  I've run into 
issues with cron jobs if I don't have it calling #!/bin/bash at the top 
(or #!/bin/[whatever]) ... running from a local terminal doesn't catch it 
because "sh somescript.sh" invokes shell first...

Although, if you're running this as "your user", then it might be failing 
out as "mount" is only permitted to be run by root (might need to add it 
to root's crontab).



Reply to: