1

I have seen here various issues about the crontab 'Operation not permitted' issue for Mac OS, but I seem to have a more complex situation on my hands.

I have a bash file on the desktop, which I wanna execute in crontab. Configurations I added:

  1. Created the file untitled.sh on my Desktop (which has #!/bin/bash in the beginning of the file).
  2. Ran 'chmod +x untitled.sh'.
  3. Using crontab -e, added the cron 0 13 * * * /Users/michael/Desktop/untitled.sh.
  4. In Security & Privacy > Privacy, gave Full Disk Permissions to iTerm, Terminal, bash & cron.

but I still get the error:

/bin/bash: /Users/michael/Desktop/untitled.sh: Operation not permitted

What can be done?

11
  • 1
    If you run the file in bash, does it work?
    – nohillside
    Dec 7, 2020 at 21:18
  • @nohillside yes it does Dec 7, 2020 at 21:42
  • Where/how do you get the error?
    – nohillside
    Dec 7, 2020 at 22:21
  • after adding the corn job and after it runs, I see the error via the mail command. Dec 8, 2020 at 6:46
  • Does anything interesting come up if you view the long list format of the file details with ls -l? I'd be interested to know what the contents of untitled.sh are, and what the results are from a cron job that points to a script containing only the line: #!/bin/bash
    – Scottmeup
    Dec 8, 2020 at 11:48

1 Answer 1

1

Posting here a partial answer to the question, from the comment section (courtesy to nohillside and scottmeup).

Seems the problem is related to the Extended Attribute com.apple.macl that was automatically assigned to the bash file on creation (discovered by running ls -la FILE_NAME, and the xattr itself from xattr FILE_NAME). This xattr was in fact attached to any file I created on the Desktop, Not sure why; I didn't manage to easily remove it by using xattr -d.

When I created the file in e.g. $HOME, it didn't have this xattr, and did run in the cron without any additional action. After moving the file from $HOME to Desktop, the cron worked as well.

You must log in to answer this question.

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