[sllug-members]: cron job environment
Shaun Kruger
shaun.kruger at gmail.com
Fri Aug 4 12:34:05 MDT 2006
> I have the following shell script:
>
>
> pathtest.sh #!/bin/sh
> echo $PATH > out
>
>
> When I sign in and run this script manually from a shell, I get the path I
> want. However, when I let this script run as a cron job for the same user, I
> get something totally different.
>
> Do you know how to configure a user's cron job so that it executes with the
> same path that the user would have in a shell after sign-in?
Another thought...
Is your script sensitive about the current working directory? Where
are you expecting the "out" file to be created? A quick look at the
cron man pages hasn't told me where it executes, but that could be a
matter of how quickly I looked.
You can answer these questions by setting MAILTO=<your email> in your
crontab file and putting the following in pathtest.sh:
echo -n "Path: "
echo $PATH
echo -n "Current Directory: "
echo `pwd`
By default anything written to standard out gets mailed to the user
who owns the job or to the MAILTO address.
If in your crontab file you manually enter your PATH= so it matches
your user's path you should be able to get the correct behavior.
Shaun
--
Visit my blog at http://hackerlog.blogspot.com
=====================================================
If more of us valued food and cheer and song above hoarded gold, it would
be a merrier world.
-- J.R.R. Tolkien
More information about the sllug-members
mailing list