2:54 PM AT command in Linux : schedule a task at later time |
AT command is used to schedule/run a command at a later time, 1 hour later, 2 mins from now, 1 week later or one month later. FORMAT DESCRIPTION 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. Example: 10 2016-04-12 17:07 a shankys
For example,
The exact definition of the time specification can be found in /usr/share/doc/packages/at/timespec. The superuser may use these commands in any case. For other users, permission to use at is determined by the files /etc/at.allow and /etc/at.deny. If the file /etc/at.allow exists, only usernames mentioned in it are allowed to use at. Options: -m Send mail to the user when the job has completed even if there was no output. This option is required when you want a mail even if there is no output of the command on the stdout. If the output of command is redirected to a file so we get nothing on the stdout. -f file Reads the job from file rather than standard input.
ATQ and at -l are the same. They are used to see the schedued jobs.
Lets schedule a job to run after 1 minute from now. Here we use stdin for the commands.
Please note that you have to press 'ctrl+d' to end the at prompt. Now we can see if the command is executed or not. Check your mails. Use mail command
Thu Apr 14 11:47:01 CEST 2016 #<-- date coammand executed /home/shanakys # <-- pwd command executed If you want to delete a task scheduled using "at", you can use atrm or at -d with the jobs number
Lets delete this job.
Lets schedule jobs using a file. We create a file containing some commands
Now we use this file to schedule jobs using -f option.
So as we see that the job is scheduled to run at 12: 10 PM today. We check mail to see if its executed or not. Prompt>mail <ENTER>
At is really useful when you have to do something at later time for one time execution. If you want to schedule a re-occuring job, you should use crontab in linux.
|
|
Related blogs
You may also like to see:
[2014-09-20] | [Open System-Linux] |
Export command in Linux |
[2014-03-11] | [Open System-Linux] |
STRINGS : a command in linux to read the non-text files |
[2015-01-18] | [Open System-Linux] |
The JAR archiving tool in Linux |
[2015-03-18] | [Open System-Linux] |
What is runlevel in Linux? |
[2014-10-04] | [Open System-Linux] |
SYSCTL : A command to configure kernel parameters at runtime in linux |
Total comments: 0 | |