Having issues making crontab run certain commands, despite the PATH and SHELL being set correctly.
Here is the env of the machine:
SHELL=/bin/bash
USER=ubuntu
MAIL=/var/mail/ubuntu
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/gopath/bin
Here is the env of cron (looks the same):
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/gopath/bin
PWD=/home/ubuntu
Then, in the crontab:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/gopath/bin
SHELL=/bin/bash
*/1 * * * * "whoami"
*/1 * * * * "whoami && which whoami"
The first whoami task succeeds, but the second fails with:
/bin/bash: whoami && which whoami: command not found
because which is not found. However, this is quite strange as:
$ which whoami
/usr/bin/whoami
$ which which
/usr/bin/which
And /usr/bin is on the PATH in cron. What gives?
echo $pathwithin the context of thewhoamiandwhich whoamicommands. Full paths within CronTab commands are a generally accepted best practice. You can also try to set your path as follows:PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/binIt seems like your $PATH has a lot of $CRUD in it, sir.