[lug] CRON and PATH
David L. Anselmi
anselmi at anselmi.us
Tue Mar 21 10:50:18 MST 2006
Gordon Golding wrote:
> I'm not getting my Path when I run a backup out of cron.
>
> I'm root running on bash, when I sign on and echo PATH, I get my full path - set in /etc/bashrc.
> When I run a script from cron and echo PATH, I get /usr/bin:/bin - as
> if I didn't run root/.bash_profile|.bashrc etc/bashrc
> I have many other machines which set path correctly out of cron.
> I compare the above files with a "good" machine and they are byte identical.
Which cron? Is this root's crontab or one of the /etc files? Is
/bin/sh and cron the same on the good & bad machines?
crontab(5) for Vixie cron says:
"Several environment variables are set up automatically by the
cron(8) daemon. SHELL is set to /bin/sh, and LOGNAME and HOME are set
from the /etc/passwd line of the crontab's owner. PATH is set to
"/usr/bin:/bin"."
On Linux, /bin/sh is usually bash. When run from cron it probably isn't
an interactive or login shell so neither ~/.bash_profile nor ~/.bashrc
would be run (but see BASH_ENV under INVOCATION in bash(1)).
HTH,
Dave
More information about the LUG
mailing list