I’m trying to write a cron job that runs a report, and emails the result to an address defined in my user’s ~/.bashrc file. I had this working perfectly on Fedora, but when I switched to Ubuntu, my solution no longer works. The command my cron job currently runs is:
. /home/myuser/.bashrc; /home/myuser/bin/runreport
If I run that command manually, or start it via Gnome-Schedule, it works perfectly, but it never seems to run. Is there something specific to Ubuntu that would be blocking this from running?
Output of crontab -l:
0 8 * * * . /home/myuser/.bashrc; /home/myuser/bin/runreport # JOB_ID_1
Output of grep -i cron /var/log/syslog:
Aug 4 08:00:00 localhost CRON[23234]: (myuser) CMD (. /home/myuser/.bashrc; /home/myuser/bin/runreport # JOB_ID_1)
If
/home/myuser/bin/runreportis a script, add the following two lines to the top:and change the
crontabline to:Then, when it runs, you should have all the environment variables, and the commands that were run, in the
/tmp/qqfile.If it isn’t a script, make a script that calls it and add the
envline to it. That will at least give you the environment you’re running in.