Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use the 'at' command to schedule tasks UNIX
Tiger only hintI don't know if this is new to people, but I just discovered that the *NIX at command finally works in OS X Tiger. I know that I've tried getting it to work since 10.0, with no luck (but maybe I missed it in 10.3).

For those of you unfamiliar with it, at allows you to run command line tasks at a specified date and time. I first used it when I was teaching, and wanted to post exam answers at a specified time (after the exam was given). I could put the answer-key html file on the website the day before I wanted it viewable, but set the chmod to disallow access. Then I would issue the command:
$ at 3:30pm tomorrow [hit return]
chmod +r exam1key.html [hit return]
[hit Control-D]
I've found this command to be very useful in scheduling one-off kinds of events, like running a job late at night or even setting reminders.

If you look at the man page (man at), it tells you that this is turned off by default, but you can enable it with this command:
$ sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.atrun.plist
I am pretty sure you have to reboot the machine for it to kick in. I highly recommend checking out the man page, since you'll see how straightforward this tool is. Ff you aren't familiar with these other useful command line tools, also check out nice (and renice) and nohup.

[robg adds: There's a much older hint that covers using at in OS X 10.2 (and maybe 10.1; the hint was posted the day 10.2 was released). However, since the activation method has changed with Tiger, I felt it worth posting this revised version.]
    •    
  • Currently 2.60 / 5
  You rated: 1 / 5 (5 votes cast)
 
[23,324 views]  

Use the 'at' command to schedule tasks | 6 comments | Create New Account
Click here to return to the 'Use the 'at' command to schedule tasks' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
power management?
Authored by: keaka on Sep 26, '05 08:16:31AM

Looks pretty nifty. However, the man page says the command has been "disabled due to power management concerns". Anybody know exactly what those concerns are? Is this going to prevent idle sleep?

---

Sanity Software: http://keakaj.com/



[ Reply to This | # ]
power management?
Authored by: googoo on Sep 26, '05 09:48:57AM

I think that the concern is that the "at" commands will not execute if the computer is asleep or off. I have not tested this, though.

-Mark



[ Reply to This | # ]
power management?
Authored by: radiola on Sep 26, '05 03:03:17PM

I think the concern is that atrun, which actually runs the at jobs, will hit the hard drive every so often (defaulting to five or ten minutes) to check for jobs. If a PowerBook user set their hard drive (but not the processor) to go to sleep after a while, it'd be spun right back up the next time at checked for jobs, regardless of whether there was a job to run or not.

If the whole computer is asleep, then cron jobs and launchd aren't running, so an at job won't wake a sleeping system up.



[ Reply to This | # ]
power management?
Authored by: tw-nym on Oct 25, '05 10:04:50AM

atd relies on cron to run its jobs. cron doesn't cause any "power management" issues because it preloads the table into memory and reloads after updates.

at is a cronjob, which by default is scheduled to run every minute. It scans its directory for jobs that have expired and runs them. With 1 disk hit per minute, the drive will not sleep much which causes problems, especially on laptops.



[ Reply to This | # ]
Use the 'at' command to schedule tasks
Authored by: derekhed on Sep 26, '05 11:27:15AM

Thanks for this. FYI, I found that I did not need to reboot the machine for it to begin working.



[ Reply to This | # ]
Use the 'at' command to schedule tasks
Authored by: fracai on Sep 27, '05 06:46:54AM
I use the sleep command to get pretty much the same effect

sleep "delay in seconds" ; command

I always run under screen so I'll sometimes toss in screen -d to run "in the background"

of course a script containing
sleep "x"
command


could be run in the background with & as well

---
i am jack's amusing sig file

[ Reply to This | # ]