Restoring Cron Job Functionality in MacOS

I have used cron jobs to do database backups and other maintenance on servers I have run at home, previously on versions of Ubuntu and Linux Mint, and currently on MacOS. Some change that happened to MacOS between the "Mojave" and "Big Sur" versions broke cron jobs that had worked for years. A cron job that would create a database restore query was suddenly creating an empty file on its daily scheduled run. The job that was supposed to update my SSL certificate when it was due for renewal never succeeded in updating it.

As I searched for a solution to this problem, I came across multiple recommendations for two different items, and the combination of the two of them has resulted in my cron jobs working again.

  1. Make sure the full path is specified for all programs and script files executed, both within the cron job itself, and within the script files that it calls. This is probably the true solution, of the two items.
  2. Make sure that cron has "Full Disk Access". For Big Sur, this is found in
    • System Preferences
    • Security & Privacy
    • [Click the lock to make changes - unless already unlocked]
    • Check "cron".
      • If "cron" is not shown as an option, hit the "+" key under the list and add /usr/sbin/cron [Enter "which cron" in a terminal session to confirm the path].

While Apple recommends switching to using launchcd with .plist files - which would also require specifying full paths for called scripts, from what I could see by trying that switch - I am more comfortable with cron, which seems more flexible, and a lot less verbose. Also, the cron concepts are much easier to translate to Linux, Unix distributions, and even using cron scheduling for Spring applications.

If any other Mac users fall into my category of knowing just enough to be dangerous with running scheduled jobs on them, and they come across the same issue with preexisting cron jobs breaking with version upgrades, I hope these quick tips come in helpful.

Comments

Popular posts from this blog

Using KeePass with Dropbox for Cross-Platform Password Management

Visiting CareLink Site on OS X Mavericks

Website FINALLY Adapted to Apple Silicon