Apple - cronjobs do not run

  • grant permissions for cron and possible the terminal apps / command line tools to run on Catalina.
  • check for full paths everywhere...
  • consider putting your commands in a script so you can debug them and avoid needing to escape characters like % or run cron in debug/test mode

I'd recommend a couple of things:

  1. Make sure cron has Full Disk Access in the Privacy tab of System Preferences (see s/s below) enter image description here
  1. When creating commands in crontab, help yourself out by writing errors generated by stderr to an output file using 2>&1, and using full pathnames (your cron job does not run w/ same environment as your user does);

EXAMPLE:

seamus@Dung-Pro ~ % crontab -l 

*/5 * * * * /usr/bin/touch /Users/seamus/scripts/cronjob-success-"$(date)".txt

SOME OTHER IDEAS:

  1. crontab guru: https://crontab.guru/

  2. not always necessary, but using full path to command is a good habit!

  3. it often helps to re-direct stderr (aka 2) to a file for review when things go wrong

  4. re-direct may be done as follows:
    >> /home/pi/cronjoblog 2>&1

    This redirects stdout to /home/pi/cronjoblog and redirects stderr to stdout; i.e. both streams will be written to the file.

Finally, wrt the specific command in your question: that does not run for me either - it has something to do with the formatting specified for the date command - date with no formatting works fine. If you need that specific command to run under cron, I'll need to do some debugging - let us know. Otherwise, the info above may help get you started.