Mailing List Archive


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

Re: [tlug] Crontab not executing



On Sun, Mar 25, 2007 at 08:45:35AM +0900, Dave M G wrote:
> TLUG,
> 
> I have a shell script that I want to run once daily at 12 PM (noon) every day. 
> The shell script is of my own creation, and it works when I execute it from the 
> command line.
> 
> However, it's not successfully being executed by cron.
> 
> Here is what I put into my crontab file:
> 
> 0 12 * * * sh /home/dave/myShellScript.sh
> 
> Have I messed up my syntax or something?

As I think you know, cron has a very short default $PATH, just /usr/bin/
and /usr/sbin/ /bin and /sbin, I think. 

(This varies by O/S, but usually, it's something like those 4.)

So, almost everything needs its full path. 
For example, on FreeBSD, both sudo and rysnc are in /usr/local/bin.

If my crontab is /usr/home/scottro/bin/rsyncbkup.sh and that shell
contains the commands sudo and/or rsync, what do you think will happen?

The script itself has to contain the full paths, e.g

/usr/local/bin/sudo /usr/local/bin/rsync cp full/path/to_whatever
full/pathto_newplace/

(cp is in /usr/bin, so I don't have to give its full path.)

So, check the commands in your script and make sure that they're in
cron's $PATH or that you have the full path to each command in the
script. 

In FreeBSD, at least, the default $PATH for cron is shown in
/etc/crontab.

-- 

Scott Robbins

PGP keyID EB3467D6
( 1B48 077D 66F6 9DB0 FDC2 A409 FA54 EB34 67D6 )
gpg --keyserver pgp.mit.edu --recv-keys EB3467D6

Buffy: I gotta stop him before he unleashes unholy havoc and 
it's just another Tuesday night in Sunnydale. 


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links