Schedule a Task with 'at' command

Linux provides a really easy way to schedule future events so they run automatically. We can use the 'at' command to schedule reminders or administrative tasks or to run a command later when the computer won't be busy. 
 
After we specify the time (and optional date) for your event, at prompts you for the command to run. After entering your command, press ctrl-D to finish.
 


Syntax:

at TIME [ DATE ]
 
Here are some examples:
at 8:15am Jul 14
echo "Remember to call"
^D
at midnight Monday
cp project/source backup
^D
To find out what events you have already scheduled with at, enter the following:


at -l
Date Owner Queue Job#
08:15:00 07/14/97 root c 1
00:00:00 01/10/97 root c 2


To cancel an event scheduled with at, use the -r switch and a job number (which you can find using the at -l command). For example, to cancel job 2, you would ent er


at -r 2




at now + 5 minutes < $HOME/listofcommands.txt


The Linux at command argument time can be one of the following:

HH:MM format — For example, 04:00 specifies 4:00AM. If the time is already past, it is executed at the specified time the next day.

midnight — Specifies 12:00AM.

noon — Specifies 12:00PM.

teatime — Specifies 4:00PM.

month-name day year format — For example, January 15 2002 specifies the 15th day of January in the year 2002. The year is optional.

MMDDYY, MM/DD/YY, or MM.DD.YY formats — For example, 011502 for the 15th day of January in the year 2002.

now + time — time is in minutes, hours, days, or weeks. For example, now + 5 days specifies that the command should be executed at the same time in five days.



=> at - executes commands at a specified time.
=> atq - lists the user's pending jobs, unless the user is the superuser; in that case, everybody's jobs are listed. The format of the output lines (one for each job) is: Job number, date, hour, job class.
=> atrm - deletes jobs, identified by their job number.
batch executes commands when system load levels permit; in other words, when the load average drops below 1.5, or the value specified in the invocation of atrun.

No comments:

Post a Comment