Operation not permitted when running a script from crontab

Hello!


I have a problem that I bash file run from cron gives ”bash: operation not permitted”.

In crontab I have:

19,34 * * * * /Users/rickiekaveby/Documents/perl/uah/fix_uah.sh >/tmp/stdout.log 2>/tmp/stderr.log


When the script has run from crontab /tmp/stderr.log looks like this:

/bin/bash: /Users/rickiekaveby/Documents/perl/uah/fix_uah.sh: Operation not permitted


The script start with

#!/bin/bash


Running the script in terminal is working ok:

cd /Users/rickiekaveby/Documents/perl/uah; ./fix_uah.sh

Rickies-MacBook-Pro:uah rickiekaveby$


The script creates some files in /Users/rickiekaveby/Documents/perl/uah

I have added full disk access for bash and terminal, so that’s not the problem. 


Thankful for any hint!


Rickie

MacBook Pro 15″, macOS 12.6

Posted on Jan 6, 2023 01:08 AM

Reply
Question marked as Top-ranking reply

Posted on Jan 8, 2023 05:10 AM

In the Full Disk Access preferences, click on the + icon


press: Command-Shift-Period


This will show hidden files in file select dialog window.


navigate to the directory with cron


select cron


You press the Command-Shift-Period keys again to toggle the showing of hidden files so they are hidden again.

6 replies

Jan 6, 2023 05:54 AM in response to rickiefromstockholm

It sounds like whatever user is running the Cron job does not have access to your documents, folder. bash and Terminal are not the users in this case.


I don’t use cron, so I’m not sure, but I think cron runs as root, and root probably doesn’t have access to your Desktop, Documents, and Downloads folder per Ventura’s privacy model.

You may be able to set it up to run as your user, but that’s beyond my knowledge of cron.

Does the script run on files in your Documents folder? If not, you could move them to a location that root can access. I would avoid trying to give root access to the Privacy protected folders.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Operation not permitted when running a script from crontab

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.