Using at to schedule scripts
If you have some basic knowledge of UNIX you probably know about cron. But have you heard about at?
at is very similar to cron. You use it to schedule to run a program/script/command once at a specific time. A very basic example would look like this
$ at now
> date >/var/tmp/date.output
> ^D
job 1 at Mon Jun 4 21:27:13 2007
^D means you should press ctrl-d. The output says that at has scheduled a job to run at 21:27 on the 4th of June (now). If you look in /var/tmp there should be a file called date.output and it should contain a date string close to that time.
Why would you use at then you may ask. You can do exactly the same thing with cron. The nice thing with at is that it is only scheduled once. With cron you need to remember to remove the entry if you don’t want it to repeat. I use it a lot if a want to run a specific maintenance script at a specific time late at night so to not affect production servers. E.g if I want to run something at 1am in the morning I can do it like this
$ at 1:00
date >/var/tmp/date.output
job 2 at Tue Jun 5 01:00:00 2007
Also if I have a long running job and I’m worried that I may get disconnected from the server then at is a real life saver. I just run the command with at and pipe the output somewhere and I can later look at it. Sometimes when you run long running scripts that doesn’t produce much output you get disconnected from server (or most likely because your tcp session in the firewall timeout) and then the script can’t continue to run in case it wants to send you some output.
There are a lot of other interesting things you can do with at but you can start off by reading the man pages for at(1) and cron(1).
Do you need system administration assistance? If you like what you are reading please consider subscribing to the RSS feed. If you have feedback or if you find the article useful please leave a comment below.

