Today I learned why my cron task was not working.
There was a weird bug where I could run the script and it would work just fine, but when crontab ran the script, it wouldn’t work. I also knew crontab was working by running other more simple scripts.
Apparently, crontab has a different set of environment variables that it uses, compared to manually running a script. I tested by running
env > /home/dan/env-cron.txt via crontab and running
env > /home/dan/env-dan.txt myself. Here were my results:
Also, note.. regardless of script location, the working directory (
pwd) starts off at the user home (
~). My error was using relative locations from script location rather than home location.
More details on Stack Overflow: Reasons why crontab does not work