crontab Operation not permitted - cron has full disk access

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?


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