3

I have a script (which backs up, using rclone) that I can run from the Terminal or Automator after chmod a+x, with no permissions problems.

However, when this script is run in cron (or launchd), stderr shows "/bin/bash: /Users/joshua/script.sh: Operation not permitted."

I am more familiar with Ubuntu, where this approach works fine.

What do I need to do here?

Edit: The above question remains relevant, but note that launchd is the favored cron replacement for Mac, while Automator is available for application-level scheduling.

3 Answers 3

3

It looks like the proper two programs to give full access to are:

cron
terminal.app

See rsync in cron on Catalina no longer working

2
  • Thank you. But (1) I am using rclone, not rsync. Does the same apply to rclone? (2) Doesn't it seem from the error that the program failing on authorization errors is bash rather than rclone? (3) Why the terminal.app? This is a background process.
    – Joshua Fox
    Commented Nov 17, 2019 at 15:22
  • 1
    Add cron, that should be all since your terminal is working. @JoshuaFox
    – bmike
    Commented Nov 17, 2019 at 15:33
0

The solution that worked for me is to use Automator, not cron, as in this example.

-2

There is two solutions that you can try. The first one I recommend however the second one might also help but it is not an ideal solution.

First Solution: Assuming, you are on macOS higher than 10.12

  1. 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

enter image description here

  1. Navigate to the /Applications/Utilities/ folder and choose “Terminal” to grant Terminal with Full Disk Access privileges

enter image description here

  1. Relaunch Terminal, the “Operation not permitted” error messages will be gone

Second solution (I personally don't recommend this)

  1. Reboot your Mac into Recovery Mode by restarting your computer and holding down Command+R until the Apple logo appears on your screen.

  2. Click Utilities > Terminal.

  3. In the Terminal window, type in:

      csrutil disable
    
  4. Restart your Mac.

9
  • Thank you, but the program that needs permissions seems to be cron, not Terminal. In fact, Terminal already had these permissions and the script would run from Terminal. I tried your instructions, and got the same error from cron. Also, I think the permission needed is to run a script, not Full Disk Access. How do I give the permissions needed here ?
    – Joshua Fox
    Commented Nov 4, 2019 at 12:44
  • You should add cron to “System Preferences > Security & Privacy > Full Disk Access”. I did this by running open /usr/bin/, which opened a Finder window that allowed me to easily drag/drop the cron program into the “Full Disk Access” list.
    – Udhy
    Commented Nov 4, 2019 at 12:49
  • There is no cron in /usr/bin. ls /usr/bin/cron* shows ` /usr/bin/crontabonly -- so is that the one that should get permissions?
    – Joshua Fox
    Commented Nov 4, 2019 at 13:23
  • 2
    cron might be in /bin, /sbin or /usr/sbin. Enabling crontab will not help.
    – nohillside
    Commented Nov 4, 2019 at 14:10
  • 1
    Don't keep the script in a user folder. You're being stopped because cron runs as root, not as you, and thus does not have access to the directory location of the script. Commented Nov 4, 2019 at 18:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .