In the monitor shell script, $USER
returns blank when run from a user's crontab? However, $USER
returns "experiment" when the script is run from the command line.
# CRON: execute monitor script every minute on user:experiment
*/1 * * * * /home/experiment/monitor
As suggested in the comments, cron
uses a rather minimal environment, with most of the environment variables undefined, and a very short $PATH
. In many versions of crontab
, you can define the variables you need at the top of the crontab
file, like so:
USER=foo
BAR=baz
PATH=/bletch:/bazoo:"$PATH"