Re: cron script won't run

Luca Ferrari <[email protected]>
Newsgroups gmane.linux.admin
Message-ID <[email protected]>
On Tuesday 26 September 2006 10:30 Adam T. Bowen's cat, walking on the 
keyboard, wrote:
> Hi,
>
> Matthew Metzger wrote:
> > I have a script that works great when I run it from the command line,
> > but doesn't work at all when added to crontab.
>
> # cat /dev/sysadm/mantra
> The environment from within cron is not necessarily the same as that of
> an interactive shell.

It is possible to specify environment variables in the crontab file, thus to 
create an environment similar to the one the user work in interactive mode:

[t35@server 35]$ crontab -l
PATH=/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt
BASH_ENV=$HOME/.bashrc
LPDEST=stt35
MAIL=/var/mail/t35
USERNAME=""
DFENV=/home/t35/dfenv.cfg
TERMINFO=/usr/share/terminfo
DFTERMINFO=/vol1/df31d/lib/terminfo
LINES=25
COLS=80
USER=t35
DFUSER=35

10 21 * * 1-6 /your/crontab/job


Also making into your script a redirection to a log file could help finding 
out what is the problem.

Luca
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.