Introduction


Normally, we hear Linux Administrators schedule their tasks with CRON, an excellent tool to regularly perform specific tasks with recurrence. But when it comes to performing a one time task, we have another great tool that suits better when no recurrence is needed.

 

The "at" command, according to Linux Man Pages, examine or delete jobs for later execution. It is important to know that the superuser may use this command in any case. For other users, permission to use at is determined by the files /etc/at.allow and /etc/at.deny.

An empty /etc/at.deny means that every user is allowed use these commands, this is the default configuration.

 

How to Use Linux At Command to Schedule One Time Tasks on your VPS


General synopsis is:

at [-V] [-q queue] [-f file] [-mldbv] TIME

 

If you want to update your Linux server (with Yum) at 10:30 pm on the current day, you should enter:

at 10:30pm

 

You will get the console output:

at>

 

At the at> prompt enter the command you would like to execute at 10:30pm. In this case yum -y update.

at> yum -y update

Now press Enter and then Ctrl + D and it will print the job number and the time the given command will be executed, like this:

root@vps:~# at 10:30pm
warning: commands will be executed using /bin/sh
at> yum -y update
at> 
job 5 at Thu Dec  5 22:30:00 2013

 

For example, if we need to compress a file at 10:30 AM of the fifth day of December 2013, we will need to enter:

at 10:10 120513

 

Where: the date has the format MMDDYY


You will get the output:

root@vps:~# at 10:30 120513
warning: commands will be executed using /bin/sh
at>

 

At the command prompt at> you should enter the command that you would like to get executed. For instance:

at> gzip filename.ext

 

Press Ctrl + D and your final output will be like this:

root@vps:~# at 10:30
warning: commands will be executed using /bin/sh
at> at gzip filename.ext
at> 
job 6 at Thu Dec  5 10:30:00 2013

 

The file will be compressed and saved as filename.ext.gz. at 10:30 AM on the 5th of December 2013.

 

That's it there is for a basic "at" command scheduler configuration. Enjoy!

 

Test on a Miami VPS Now

or

Deploy on a Miami Dedicated Server

Was this answer helpful? 2 Users Found This Useful (13 Votes)