Date: Sat, 28 Jan 2012 16:45:01 -0800 From: Eric Bullen <barnabus.pinklehorn@gmail.com> To: freebsd-stable@freebsd.org Subject: Looks like a bug (or odd intended practice) in cron not honoring the PATH variable. Message-ID: <CAOdRyJxE4svHttHKJM5tjQYW62u=pmcCi9Cg4-ok3ePg59hUdg@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOdRyJxE4svHttHKJM5tjQYW62u=pmcCi9Cg4-ok3ePg59hUdg>