Eric Bullen
2012-Jan-29 01:15 UTC
Looks like a bug (or odd intended practice) in cron not honoring the PATH variable.
Hi All, I'm running the following: FreeBSD x 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:46:30 UTC 2012 root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64 I couldn't figure out why SOME of root's cronjobs weren't running, and others were. Here's my test crontab for root: # PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/user/local/bin # * * * * * env > /tmp/x 2>&1 * * * * * curl > /tmp/y 2>&1 The 'curl' command resides in /usr/local/bin, and the output for /tmp/x, and /tmp/y are as follows: # tail -10 /tmp/x /tmp/y ==> /tmp/x <=LOGNAME=root PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/user/local/bin PWD=/ USER=root HOME=/ SHELL=/bin/sh ==> /tmp/y <=curl: not found The man (man 5 crontab) page says the following, but it LOOKS like cron is passing the environment to the command, but doesn't take the PATH env var as defined at top. "SHELL is set to /bin/sh, PATH is set to /usr/bin:/bin, and LOGNAME and HOME are set from the /etc/passwd line of the crontab's owner. HOME, PATH and SHELL may be overridden by settings in the crontab; LOGNAME may not." Not expected behavior. Thoughts? Please don't say that I should use absolute paths in my crontabs. I am well aware of the security implications. Thanks in advance! -Eric
Doug Barton
2012-Jan-29 01:20 UTC
Looks like a bug (or odd intended practice) in cron not honoring the PATH variable.
On 01/28/2012 16:45, Eric Bullen wrote: /user/local/bin -- It's always a long day; 86400 doesn't fit into a short. Breadth of IT experience, and depth of knowledge in the DNS. Yours for the right price. :) http://SupersetSolutions.com/
Glen Barber
2012-Jan-29 01:36 UTC
Looks like a bug (or odd intended practice) in cron not honoring the PATH variable.
Hi, On Sat, Jan 28, 2012 at 04:45:01PM -0800, Eric Bullen wrote:> Hi All, > > I'm running the following: > > FreeBSD x 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:46:30 UTC > 2012 root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64 > > I couldn't figure out why SOME of root's cronjobs weren't running, and > others were. Here's my test crontab for root: > > > # > PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/user/local/binLooks to me like '/user/local/bin' is more likely the problem. It should be '/usr/local/bin' (note the lack of 'e'). Regards, Glen