OSX mojave: "crontab: tmp/tmp.X: Operation not permitted"

Solution 1:

The short answer:

Go to System Preferences > Security & Privacy and give Full Disk Access to Terminal.

The long answer:

  1. Pull down the Apple menu and choose ‘System Preferences’
  2. Choose “Security & Privacy” control panel
  3. Now select the “Privacy” tab, then from the left-side menu select “Full Disk Access”
  4. Click the lock icon in the lower left corner of the preference panel and authenticate with an admin level login
  5. Now click the [+] plus button to add an application with full disk access
  6. Navigate to the /Applications/Utilities/ folder and choose “Terminal” to grant Terminal with Full Disk Access privileges
  7. Relaunch Terminal, the “Operation not permitted” error messages will be gone

Solution 2:

Another approach without requiring any permission changes, which relies upon the fact that sshd is already enabled for 'Full Disk Access', is to perform the crontab updates via ssh to localhost (provided Remote Login/ssh is enabled in Sharing System preferences) e.g:

ssh localhost
crontab -e

Solution 3:

I had to add cron to System Preferences > Security & Privacy > Full Disk Access

  1. Find privacy preferences: CMD + Space, "priv"

  1. Unlock preferences for Full Disk Access and open selection menu

  1. In selection menu press CMD + Shift + . to unhide hidden files and navigate to /usr/sbin/cron. (You may check your cron executable location by running $ which cron in terminal)

]


Solution 4:

The sandbox is preventing you from writing the crontab. If you run the crontab command…

  • using Terminal on local machine: System Preferences > Security & Privacy and give Full Disk Access to Terminal
  • using a third party terminal app: System Preferences > Security & Privacy and give Full Disk Access to third party terminal app
  • via ssh from another machine: it should work (see @Pierz' answer)
  • from the screen command: either log out of screen or use @Pierz' answer.