command: at

Rob

Administrator
Staff member
Joined
Oct 27, 2011
Messages
846
Reaction score
1,618
Credits
669
There is a little known command in linux that is very handy when scheduling a task. Normally server administrators prefer using CRON for handling all scheduling. However, CRON is primarily designed for setting up recurring schedules and isn't really the right tool for one time jobs. If you have a server task that needs to be run at a particular time just once, then I suggest using `at`.

The syntax of at is straightforward.

COMMAND - DATE

Here is an example: (run this file at 10am, on December 24th)
Code:
at -f /usr/local/bin/reboot.pl 14:45

where reboot.pl contains
Code:
#!/usr/bin/perl
`shutdown -r now`;

Fancy things you can do with `at`.

You can get an email when the task is run by using
-m

You can change the shell that executes the job
-c -k -s (C, Korn, Bourne)

You can specify a file that contains the command to run
-f
Code:
at -f /usr/local/bin/reboot.pl 14:45
You can list the commands that `at` has in its queue
-l
Code:
at -l

You can cancel a pending `at` job
-r
Code:
at -r 9
 


TechnoJunky

Well-Known Member
Joined
Dec 3, 2018
Messages
493
Reaction score
390
Credits
314
Have you guys looked in the repository for it? It's in the Ubuntu repo.

AT is a command that comes installed on Windows by default. Didn't know there was a Linux version too.
 

calkines

New Member
Joined
Jun 11, 2020
Messages
2
Reaction score
1
Credits
12
Using Ubuntu over WSL1 on Windows causes this message: "Can't open /var/run/atd.pid to signal atd. No atd running?".

I'll try to execute with WSL2
 

kmonu963

New Member
Joined
Nov 25, 2020
Messages
1
Reaction score
0
Credits
6
at : refusing to create job destined in the past.
plz tell me how to solved this.
 

dos2unix

Well-Known Member
Joined
May 3, 2019
Messages
1,071
Reaction score
743
Credits
5,560
type crontab -e

delete the duplicate crontab, that you trying to use at for.
 

Condobloke

Well-Known Member
Joined
Apr 30, 2017
Messages
3,946
Reaction score
3,556
Credits
20,145

f33dm3bits

Gold Member
Gold Supporter
Joined
Dec 11, 2019
Messages
4,076
Reaction score
2,835
Credits
29,441

hirushaadikari

New Member
Joined
Mar 9, 2021
Messages
2
Reaction score
0
Credits
11
type crontab -e

delete the duplicate crontab, that you trying to use at for.
do we have to write the code in here in the crontab file, or just input it to the terminal ?
and can you please show the usage and an example for this command
 

TechTycho

New Member
Joined
Jul 30, 2021
Messages
3
Reaction score
0
Credits
18
:confused:In CentOS 7, "at" command seems is not a default-installed component.
CentOS is very vanilla, you have to install every single tool manually :\

Edit: ok, it doesn't work for me either (I am an Ubuntu user) maybe you type sudo yum install at if you are on CentOS, for Debian users, write: sudo apt install at
 
Last edited:
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Members online


Top