Having issues making crontab run certain commands, despite the PATH and SHELL being set correctly.Here is the env of the machine:SHELL=/bin/bashUSER=ubuntuMAIL=/var/mail/ubuntuPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/gopath/binHere is the env of cron (looks the same):SHELL=/bin/bashPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/gopath/binPWD=/home/ubuntuThen, in the crontab:PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/gopath/binSHELL=/bin/bash*/1 * * * * whoami*/1 * * * * whoami && which whoamiThe first whoami task succeeds, but the second fails with:/bin/bash: whoami && which whoami: command not foundbecause which is not found. However, this is quite strange as:$ which whoami/usr/bin/whoami$ which which/usr/bin/whichAnd /usr/bin is on the PATH in cron. What gives?
cron will find certain commands on the PATH but not others
cron
You shouldn't quote the cron job.You have*/1 * * * * whoami && which whoamiWhich is looking a command literally called whoami && which whoami. Such as /usr/bin/whoami && which whoami. Obviously, this command does not exist. Remove the quotes so that the command is properly interpreted:*/1 * * * * whoami && which whoami