50

I am going to schedule a job by using at command. Here I tried the following command:

$ at now + 1 minute
echo 'Test at command'
<EOD>

I saw the job is scheduled by using at -l. However, I saw no echo out.

I guess that I may need to add user to at.allow file. I cannot find at.allow in my Mac (Snow Leopard). Not sure what I need to do to test this at command?

Chealion
  • 26,327
David.Chu.ca
  • 5,535

6 Answers6

46

To enable the needed atrun daemon, as man atrun says, execute:

launchctl load -w /System/Library/LaunchDaemons/com.apple.atrun.plist

as root (e.g. via sudo). Once you've done that, /var/at/ will be the key directory (though the simplest way is to use at as root -- e.g., once again, by sudo!-).

15

In Snow Leopard you need to:

  1. Edit the /System/Library/LaunchDaemons/com.apple.atrun.plist, change the disabled child node from true -> false.

  2. Unload the current /System/Library/LaunchDaemons/com.apple.atrun.plist with:

    sudo launchctl unload -F /System/Library/LaunchDaemons/com.apple.atrun.plist
    

    Then load the edited version

    sudo launchctl load -F /System/Library/LaunchDaemons/com.apple.atrun.plist
    
  3. Test that it works with:

    echo blah | at now+1
    
  4. In case the echo fails for a different reason, you should be able to at least see the queue get cleared with:

    atq
    
muru
  • 1,336
5

I tried this on OS X Lion and it seemed to work.

First enable the atrun deamon:

launchctl load -w
/System/Library/LaunchDaemons/com.apple.atrun.plist

Then add [your username] to /var/at/at.allow.

When executed you will receive output at /var/mail/[your username]

I find that queued items with batch take a few minutes to get actually get executed.

chris838
  • 151
3

The launchctl step wasn't enough for me; Seamus's comment pointed me to a more recent answer.

The TL;DR is you also need to add /usr/libexec/atrun at System Preferences > Security & Privacy > Full Disk Access.

3

Others have replied about at being disabled on Mac OS X, and I don't know about that, but there is another problem: Where do you expect your echo command to print its message? On other Unix systems that I have used it does not print in the same shell window where you gave the at command. Remember that when the at job is run, you might not even be logged in any more.

Try to write something to a file instead, and see if that file appears at the right time.

0

My installation of OS X (10.4) says in man at:

NOTE
     at, batch, atq, atrm are all disabled by default on Mac OS X.

Have you enabled atrun according to the instructions there?

Greg Hewgill
  • 5,619