I see cron is running, but jobs in crontab do not execute

I believe this may be a permission issue, but I am unable to add cron to "full disk access"


grant@bigmac01:~[20220723-11:13][#3]% codesign -dr - /usr/sbin/cron
Executable=/usr/sbin/cron
designated => identifier "com.apple.cron" and anchor apple
grant@bigmac01:~[20220723-11:20][#4]% sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db "INSERT INTO access VALUES('kTCCServiceAccessibility','com.apple.cron',0,1,1,NULL);"
Password:
Error: in prepare, table access has 13 columns but 6 values were supplied (1)
grant@bigmac01:~[20220723-11:34][#5]%


grant@bigmac01:~[20220723-11:36][#6]% sw_vers
ProductName:    macOS
ProductVersion: 12.3
BuildVersion:   21E230
grant@bigmac01:~[20220723-11:42][#7]%


I think I'm close here, but...


see also: https://stackoverflow.com/questions/72995911/macos-monterey-cron-is-running-but-executes-nothing


Mac Studio

Posted on Jul 23, 2022 11:47 AM

Reply
Question marked as Top-ranking reply

Posted on Sep 15, 2022 5:06 AM

I resolved my issue.

On MacOS (vix cron) the option to specify a user for execution is not supported. I removed the user (root), and cron is executing.

grant@ef-io04dm:~[20220915-5:01][#72581]% sudo crontab -l
Password:
# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed
25 10,22 * * * /usr/sbin/createhomedir -c -a

grant@ef-io04dm:~[20220915-5:01][#72812]% 
4 replies
Question marked as Top-ranking reply

Sep 15, 2022 5:06 AM in response to Grant Janssen

I resolved my issue.

On MacOS (vix cron) the option to specify a user for execution is not supported. I removed the user (root), and cron is executing.

grant@ef-io04dm:~[20220915-5:01][#72581]% sudo crontab -l
Password:
# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed
25 10,22 * * * /usr/sbin/createhomedir -c -a

grant@ef-io04dm:~[20220915-5:01][#72812]% 

Jul 27, 2022 7:16 AM in response to leroydouglas

I have updated the Operating System. I see cron is running - yet executes nothing.

grant@ef-io04dm:~[20220727-7:08][#59927]% sw_vers
ProductName:    macOS
ProductVersion: 12.5
BuildVersion:   21G72
grant@ef-io04dm:~[20220727-7:08][#60111]% defaults read /System/Library/LaunchDaemons/com.vix.cron.plist
{
    EnableTransactions = 1;
    KeepAlive =     {
        PathState =         {
            "/etc/crontab" = 1;
        };
    };
    Label = "com.vix.cron";
    ProgramArguments =     (
        "/usr/sbin/cron"
    );
    QueueDirectories =     (
        "/usr/lib/cron/tabs"
    );
}
grant@ef-io04dm:~[20220727-7:08][#60295]% sudo launchctl print system/com.vix.cron
system/com.vix.cron = {
        active count = 1
        path = /System/Library/LaunchDaemons/com.vix.cron.plist
        state = running

        program = /usr/sbin/cron
        arguments = {
                /usr/sbin/cron
        }

        default environment = {
                PATH => /usr/bin:/bin:/usr/sbin:/sbin
        }

        environment = {
                MallocSpaceEfficient => 1
                XPC_SERVICE_NAME => com.vix.cron
        }

        domain = system
        minimum runtime = 10
        exit timeout = 5
        runs = 1
        pid = 928
        immediate reason = xpc event
        forks = 4
        execs = 1
        initialized = 1
        trampolined = 1
        started suspended = 0
        proxy started suspended = 0
        last exit code = (never exited)

        event triggers = {
                com.apple.launchd.QueueDirectories => {
                        keepalive = 1
                        service = com.vix.cron
                        stream = com.apple.fsevents.matching
                        monitor = com.apple.UserEventAgent-System
                        descriptor = {
                                "QueueDirectories" => [
                                        0 = "/usr/lib/cron/tabs"
                                ]
                        }
                }
                com.apple.launchd.PathState => {
                        keepalive = 0
                        service = com.vix.cron
                        stream = com.apple.fsevents.matching
                        monitor = com.apple.UserEventAgent-System
                        descriptor = {
                                "PathState" => {
                                        "/etc/crontab" => true
                                }
                        }
                }
        }

        event channels = {
                "com.apple.fsevents.matching" = {
                        port = 0x19003
                        active = 0
                        managed = 1
                        reset = 0
                        hide = 0
                        watching = 0
                }
        }

        spawn type = daemon (3)
        jetsam priority = 4
        jetsam memory limit (active, soft) = 25 MB
        jetsam memory limit (inactive, soft) = 25 MB
        jetsamproperties category = daemon
        jetsam thread limit = 32
        cpumon = default

        properties = supports transactions | inferred program | system service
}
grant@ef-io04dm:~[20220727-7:08][#60479]% ps -ax | grep cron
  928 ??         0:00.01 /usr/sbin/cron
 1491 ttys000    0:00.00 grep cron
grant@ef-io04dm:~[20220727-7:08][#60663]% sudo crontab -l
# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed
#22 9 * * * root /usr/sbin/createhomedir -c -a
*/5 * * * * root /usr/bin/touch /Users/grant/Documents/`date +%Y%m%d%H%M`
*/5 * * * * root /usr/local/bin/createuserhomedir
grant@ef-io04dm:~[20220727-7:09][#60847]%

Jul 24, 2022 1:00 PM in response to Grant Janssen

Grant Janssen wrote:

I believe this may be a permission issue, but I am unable to add cron to "full disk access"

grant@bigmac01:~[20220723-11:13][#3]% codesign -dr - /usr/sbin/cron
Executable=/usr/sbin/cron
designated => identifier "com.apple.cron" and anchor apple
grant@bigmac01:~[20220723-11:20][#4]% sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db "INSERT INTO access VALUES('kTCCServiceAccessibility','com.apple.cron',0,1,1,NULL);"
Password:
Error: in prepare, table access has 13 columns but 6 values were supplied (1)
grant@bigmac01:~[20220723-11:34][#5]%


grant@bigmac01:~[20220723-11:36][#6]% sw_vers
ProductName: macOS
ProductVersion: 12.3
BuildVersion: 21E230
grant@bigmac01:~[20220723-11:42][#7]%

I think I'm close here, but...

see also: https://stackoverflow.com/questions/72995911/macos-monterey-cron-is-running-but-executes-nothing



The current stable release of Monterey including bug fixes, is macOS 12.5


Keep your Mac up to date - Apple Support

Keep your Mac up to date - Apple Support


Sep 3, 2022 8:20 AM in response to Grant Janssen

Since I was unable to add cron to "Full Disk Access" via CLI, I did this though the UI

grant@ef-io04dm:~[20220903-7:14][#70108]% sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db 'select client,auth_value from access where service = "kTCCServiceSystemPolicyAllFiles"'
Password:
/usr/libexec/sshd-keygen-wrapper|2
/usr/sbin/cron|2
com.apple.Terminal|2
grant@ef-io04dm:~[20220903-7:26][#70329]%

My cron executions still fail.

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.

I see cron is running, but jobs in crontab do not execute

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