Re: cron jobs not running as root

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Darin Wayrynen
Date:  
To: plug-discuss
New-Topics: DNS I think
Subject: Re: cron jobs not running as root
> Date: Tue, 27 Jul 2004 15:35:31 -0700
> From:
> To: PLUG <>
> Subject: cron jobs not running as root
> Reply-To:
>
> I have created a cron job and while logged in as root the scipt runs
> fine but if I configure crontab like contab -u root -e the job does not
> run.
>
> I do see the job start in /var/log/syslog
>
> The way that I know the job does not work sucessfully is becuase part of
> the job is to send out an email and that is not working unless running
> it at the command prompt as root.
>
> Jim


Hello Jim,

As pointed out earlier, the environment the cronjob is executed in is
different than when the script manually.

More often than not, paths to the binaries in your script are not in
the PATH environment when executed under crontab.

If you crontab entry is just a list of commands all piped together you
can implicitly set the path to the binaries:

ie. if your crontab command is:

    whois mydomain | mail 


and whois is in /usr/bin and mail is in /bin then change that to

    /usr/bin/whois mydomain | /bin/mail 


Alternatively, if the script is in it's own file, just set up the PATH
variable at the top of the script file to make sure all the necessary
binary paths are in that variable.

Darin










---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss