Linux Know-How provides a collection of introductory texts on often needed Linux skills.


Scheduled Programs

The at command will execute the command(s) you specify at the date and time of your choice. For example, I could start playing music from my CDROM at 7 o'clock in the morning:

at 7:00

cdplay<Ctrl>d

In the example above, I entered the first line "at 7:00" on the command line and then pressed ENTER. To this, the at command displayed a prompt "at>". At this prompt, I entered my command "cdplay" and then pressed the control key and "d" simultaneously to finish the input. If instead of pressing <Ctrl>d , I pressed "ENTER", the next "at>" prompt would appear, at which I would be able to enter the next command to be executed right after "cdplay", also at 7:00. And so on, I could have had many commands scheduled for execution one by one starting at 7:00. After typing the last command, I would finish the input with <Ctrl>d. Think of the <Ctrl>d as sending "end-of-file" to the current input. Don't press <Ctrl>d twice because this will log you out--that's what <Ctrl>d does when entered straight on the Linux command line.

You can list the job you scheduled for execution using:

at -l

which will give you the numbered list of the jobs waiting.

If you changed your mind, you can remove a job from this list. For example:

atrm 8

will remove the job with the number eight on the list.

I could also schedule a job for execution much later, for example:

at 23:55 12/31/00

startx

would start my X-windowing system right on time for the new millennium (5 minutes before midnight on 31 of December 2000).

If you cannot execute the at command, check if the at daemon ("atd") is loaded (as root, use ntsysv). If you cannot execute the at command as a regular user although it works for root, check if the empty file /etc/at.deny exists and there is no file /etc/at.allow. This should be the default setup and it permits all the users to execute at. If you want only certain users to use at, create a file /etc/at.allow and list these users there.

For other options, check:

man at

If you wish to perform a processor-intensive job in the background when the system load is low, you may choose to use the batch command. For example, I could run setiathome (a program crunching data to help in search of extraterrestrial intelligence, SETI) using:

batch

at>setiathome<Ctrl>d

In this example, I entered the command batch and then, at the "at>" prompt, I entered the command which I wanted to be executed in the background. The job tries to start immediately, but goes ahead only when the system load is under 0.8 You can check the system load by inspecting the contents of the (virtual) file /proc/loadavg . For example:

cat /proc/loadavg

When a batch job finishes, the output is sent to me via e-mail.


Last Update: 2010-12-16