how to Schedule task or job in Linux using at Command

Task Schedule using AT command..

“AT” allows Linux and Unix users to run commands or scripts at a given date and time. You can schedule scripts to be executed periodically. It is usually used for sysadmin jobs such as backups or cleaning /tmp/ directories and more.

“AT” is used to schedule the job for a particular time or interval, in other words it is used only for one time or only for one interval.

The disadvantages of at jobs are

  • It can be modified like cron jobs
  • It cannot be reused
  • The content cannot to viewed in normal human readable format

Schedule at job to display current date on current console “now”

To schedule above job using at first check the which console you are using…

#tty

 

The Syntax to use at job for this task is

#at <time>

TASK

Ctrl+d to save it.

#at now

 

 

It is very similar to above task, use the following command..Schedule at job to get a mail at 04 : 30 PM regarding conference call.

# at 04.30pm

 

 

#at 10.30am + 3daysHow to schedule at job to get a mail at 11.30 Am till three days from now for a metting.

 

 

# at –l or # atqHow To check the list of at jobs

 

 

# at –c <job id>How to check what is scheduled in at job

# at –c 6

Note : the output will not be in human readable format and also very lengthy

 

 

First check the job itHow to remove at jobs

To remove a at job the syntax is:

#atrm <job id>

#atrm 6

#atrm 5

 

 

For restricting a user for using at job use following methods.How to restrict a user for using at jobs.

  • To restrict a user from using at jobs it is exactly same like cron jobs
  • Add user names to /etc/at.deny , It will work like exactly same like cron.deny.
  • To allow only few out of many users remove at.deny like we do for cron.deny and create /etc/at.allow and add user names who are allowed to use at jobs in it, like cron.allow.
  • If both at.allow and at.deny exists, then at.allow will have higher priority.
  • If neither at.allow nor at.deny exists, then only root can use at jobs.

All the above are few examples of at jobs, keep practicing to know more about it… If you have any problem then comment me..

Leave a Reply

Your email address will not be published. Required fields are marked *