I am working on a CentOS server and schedule a task with command at
# echo "touch a_long_file_name_file.txt" | at now + 1 minute job 2 at Wed Oct 31 13:52:00 2018
One minute later,
# ls | grep a_long_file_name_file.tx a_long_file_name_file.txt
the file was successful created.
However, if I run it locally on my macOS,
$ echo "touch a_long_file_name_file.txt" | at now + 1 minute job 31 at Wed Oct 31 13:58:00 2018
Minutes later, if it failed to make such a file.
I checked the version of at on the CentOS server
AUTHOR: At was mostly written by Thomas Koenig, <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="48212f7a7d083a32663d26216523293a243b3a3d202d662c2d66">[email protected]</a> 2009-11-14
In contrast, the macOS version
AUTHORS
At was mostly written by Thomas Koenig <<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b9d0de8b8cf9cbc397ccd7d094d2d8cbd5cacbccd1dc97dddc">[email protected]</a>>. The time parsing routines are
by
David Parsons <<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ed829f8ead9d888181c38e8584c38481c3989e">[email protected]</a>>, with minor enhancements by
Joe Halpin <<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7a10151f54121b160a13143a1b0e0e181354191517">[email protected]</a>>.
BSD January 13, 2002
I found that at, atq, atrm are not of GNU coreutils.
$ ls /usr/local/opt/coreutils/libexec/gnubin/ | grep at cat date pathchk realpath stat truncate
How could I install the latest version of at on macOS and make it work?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Instead of updating at and the associated tools on macOS, lets try to make the default at on macOS work.
The at manual on macOS says (my emphasis):
IMPLEMENTATION NOTES
Note that
atis implemented through thelaunchd(8)daemon periodically invokingatrun(8), which is disabled by default. Seeatrun(8)for information about enablingatrun.
Checking the atrun manual:
DESCRIPTION
The
atrunutility runs commands queued byat(1). It is invoked periodically bylaunchd(8)as specified in thecom.apple.atrun.plistproperty list. By default the property list contains the Disabled
key set to true, soatrunis never invoked.Execute the following command as root to enable
atrun:launchctl load -w /System/Library/LaunchDaemons/com.apple.atrun.plist
What I think may be happening here, and what is prompting your other at-related questions, is that you just haven’t enabled atrun on your macOS installation.
On macOS Mojave, in addition to running the above launchctl command (with sudo), you will also have to add /usr/libexec/atrun to the list of commands/applications that have “Full Disk Access” in the “Security & Privacy” preferences on the system. Note that I don’t know the security implications of doing this. Personally, I have also added /usr/sbin/cron there to get cron jobs to work (not shown in the screenshot below as this is from another computer).
To add a command from the /usr path (which won’t show up in the file selection dialog on macOS), press Cmd+Shift+G when the file selection dialog is open (after pressing the plus-icon/button in the bottom of the window).
You do not need to reboot the machine after these changes. I have tested this on macOS Mojave 14.10.1.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0
