root's default PATH is
$ sudo su
# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
After creating /etc/cron.d/myjob
35 * * * * tim ( date && echo $PATH && date ) > /tmp/cron.log 2>&1
/tmp/cron.log
shows the default value of PATH is:
/usr/bin:/bin
Is the default PATH value in a crontab file not the one for the root? Why?
Whose PATH value is it?
WIll the default PATH value be different if I add the job in /etc/crontab
or a file under /etc/cronb.d/
?
Does it matter which user is specified in the cron job? (such as tim
in the above example)
Thanks.
/usr/bin:/bin
, and in Ubuntu 22.04 the default PATH is/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
, quite the mouthful! (even for users other than root. that was unexpected! it's a sudo group member though..) – hanshenrik May 22 '23 at 06:38