How to use command "at" to execute shell in MacOS

macos, shell

Solution

I noticed "SEE ALSO" in man page of at:

SEE ALSO
nice(1), sh(1), umask(2), campact(5), atrun(8), cron(8), sendmail(8)

In atrun(8), a solution is provided.

Execute the following command as root to enable atrun:
launchctl load -w
/System/Library/LaunchDaemons/com.apple.atrun.plist

After I sudo this command, and then restart my computer, at become available.

Problem

I want to execute some shell script once in MacOS. At first, I tried the "at" command in Ubuntu and it performed well. But when I use same method in MacOS, things goes wrong I typed: ``` $ at now + 2 minutes ls -al > tmpfile (ctrl+d,EOF) ``` The job was added successfully. The output of "at -l" is: ``` (some other output) 11 Fri Jul 19 15:18:00 2013 ``` But after 15:18 ,tmpfile was not changed. I want to know how to use "at" command in MacOS corectly or is there any other method to execute some shell script at certain time once(not periodic)

Original source

Related problems