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

Re: Cron not working



Quoting Haines Brown (haines@histomat.net):
> On Sun, Jul 12, 2015 at 06:33:40PM +0000, Dan Purgert wrote:
> > 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...
> 
> My backup script begins with the line: #!/bin/sh. I'm changing it to
> #!/bin/bash just in case.

You could also put lines like
SHELL=/bin/bash
MAILTO=haines@localhost
at the top of your crontab if you rely overmuch on bash.

While a lot of system files of this ilk could benefit from a
#
at the end, I don't *think* that's an issue here because crontab is
meant to check the file when you install it. Perhaps.

> > 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).
> 
> No, when run manually I run it as root. I would get a partial backup
> otherwise. The mount command works fine. I don't see why root's cron
> would have any problem with it.

Well, that depends what filesystem your external drive has. Is it by
any chance a bog-standard retail drive with NTFS on it? If so, mount
will fail in a cron job because /sbin is not in your path.

and if you're tempted to put
PATH=$PATH:/sbin:/usr/sbin
at the top of crontab, that will fail too.

Type   man 5 crontab   to visit the crazy World of Cron.

Oh, and why wait till next Sunday? Just change the times in the file.
And prefix bits of (c) through (f) with echo commands or suchlike.

Cheers,
David.


Reply to: