macOS cron Permission Issues

I use macOS at work, and I have a number of cron jobs that I set to run.

One of the jobs run’s on a regular basis, and is supposed to delete the public/ directory of a Hugo static site, and then rebuild the site. Trouble is it always fails to remove the directory because it doesn’t have permissions to do it.

rm: /Users/jprice/drive/my/files/documents/log/public: Operation not permitted

It’s a “simple” enough fix. To get around it you have to give /usr/sbin/cron Full Disk Access in macOS.

To do that go to “System Settings > Privacy & Security > Full Disk Access”, and click to the + to add cron. There’s no command you can run to do this in one it seems ☹️ and you’ll need admin permissions.