3 ms·
Another thing to watch with cron is that its environment is NOT the same as running a script from your CLI, unless you specifically set those environment variab
by mindcrime 6y ago
Another thing to watch with cron is that its environment is NOT the same as running a script from your CLI, unless you specifically set those environment variables in your crontab.
Yep. This is one big reason so many scripts work fine from the CLI, then fail when run under cron. I've been bitten by that before.
For me, the script I was just working on was prototyped from the command line, logged in as a regular user. It wound up using sudo and running under the user crontab, and then ran into this very problem. It's not something I consider important enough to change, but you have a good point. It would be cleaner to just run it under the root crontab in the first place.