how do I turn ON 'cron' (crontabs), 'at', and 'batch'

There is an historical UNIX-like feature whereby a user can run periodic jobs in the background (at specified times and dates). This facility was referred to either as the 'cron' or 'crontab' facility. Continuing scheduled background jobs were setup using a command called 'crontab'. The facility also (historically) had an associated feature known as 'at' jobs and 'batch' jobs. There were historical commands called 'at' and 'batch' that allowed users to submit jobs for background execution at specified times and-or dates. Question: On macOS Catalina (at least on that version) these facilities come (as shipped) in a disabled or OFF state. The question is: how does one turn these facilities ON (or ENABLE them)?


Posted on Dec 16, 2023 1:59 PM

Reply
Question marked as Top-ranking reply

Posted on Dec 16, 2023 2:23 PM

I think an answer to this question may be as follows:

So called 'cron' jobs (background scheduled jobs setup using the 'crontab' command) and the 'at' and 'batch' commands require individual enablements. These two facilities ('crontab' being one, and 'at' and 'batch' being the other) operate (apparently) independently under MacOS.

So-called 'cron' ('crontab' jobs) are enabled by making the 'cron' program itself (located at the system path '/usr/sbin/cron') have the "Full Disk Access" property (I do not really know what this "property" is really called).

This is done using the MacOS 'System Preferences' -> 'Security & Privacy' -> (menu-pick on left side) 'Full Disk Access' panel. Once there, locate the 'cron' program in the file-system using the Finder (must use the pull-down menu 'Go' -> 'Go to folder ...' feature to get to it. Once there, drag and drop the 'cron' program (again, located at the system file-path of '/usr/sbin/cron') into the list of programs on the 'System Preferences' panel opened already. Make sure the little check-box is checked to enable to the program. Now, do the same for the 'at' and 'batch' programs. Also, (kind of secretly) you must also to this for the 'atrun' program (located at '/usr/libexec/atrun'). This last item (the 'atrun' program) is the actual daemon program used to run 'at' and 'batch' jobs. In this implementation of MacOS (unlike many older historical UNIX-like OSes) the 'at' and 'batch' commands ('batch' is actually 'at' in disguise, if you did not already know) are implemented using the 'atrun' daemon rather than the 'cron' daemon (as was the case in the original implementation). Finally, you may need to ENABLE the 'atrun' facility in MacOS by turning it ON for use with the LaunchDaemon ('launchd') facilitate using the 'launchctl' command. This is done with a command like ' launchctl load -w /System/Library/LaunchDaemons/com.apple.atrun.plist'. This last thing may have to be done while executing as 'root' (I forget the details). For additional questions on these kinds of enablements or 'launchctl' actions, you should be able to search either in the Apple-Support forum or search on-line in general. I am not aware on whether Apple has made this above information available in some document or other (for regular users), but I could not find anything on it with a reasonable search. So hopefully this question and associated answer can be found with a search. Enjoy.

1 reply
Question marked as Top-ranking reply

Dec 16, 2023 2:23 PM in response to SadUser

I think an answer to this question may be as follows:

So called 'cron' jobs (background scheduled jobs setup using the 'crontab' command) and the 'at' and 'batch' commands require individual enablements. These two facilities ('crontab' being one, and 'at' and 'batch' being the other) operate (apparently) independently under MacOS.

So-called 'cron' ('crontab' jobs) are enabled by making the 'cron' program itself (located at the system path '/usr/sbin/cron') have the "Full Disk Access" property (I do not really know what this "property" is really called).

This is done using the MacOS 'System Preferences' -> 'Security & Privacy' -> (menu-pick on left side) 'Full Disk Access' panel. Once there, locate the 'cron' program in the file-system using the Finder (must use the pull-down menu 'Go' -> 'Go to folder ...' feature to get to it. Once there, drag and drop the 'cron' program (again, located at the system file-path of '/usr/sbin/cron') into the list of programs on the 'System Preferences' panel opened already. Make sure the little check-box is checked to enable to the program. Now, do the same for the 'at' and 'batch' programs. Also, (kind of secretly) you must also to this for the 'atrun' program (located at '/usr/libexec/atrun'). This last item (the 'atrun' program) is the actual daemon program used to run 'at' and 'batch' jobs. In this implementation of MacOS (unlike many older historical UNIX-like OSes) the 'at' and 'batch' commands ('batch' is actually 'at' in disguise, if you did not already know) are implemented using the 'atrun' daemon rather than the 'cron' daemon (as was the case in the original implementation). Finally, you may need to ENABLE the 'atrun' facility in MacOS by turning it ON for use with the LaunchDaemon ('launchd') facilitate using the 'launchctl' command. This is done with a command like ' launchctl load -w /System/Library/LaunchDaemons/com.apple.atrun.plist'. This last thing may have to be done while executing as 'root' (I forget the details). For additional questions on these kinds of enablements or 'launchctl' actions, you should be able to search either in the Apple-Support forum or search on-line in general. I am not aware on whether Apple has made this above information available in some document or other (for regular users), but I could not find anything on it with a reasonable search. So hopefully this question and associated answer can be found with a search. Enjoy.

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.

how do I turn ON 'cron' (crontabs), 'at', and 'batch'

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