Unlike the the cron job is mainly used to schedule repetitive tasks, the “at” command is used to run a command just once, but schedule at a later time.
That yum package to be installed is at
[root@centos9vm ~]# dnf install at -y
[root@centos9vm ~]# systemctl start atd
[root@centos9vm ~]# systemctl enable atd
The below command created a file 1 min from now
[root@centos9vm ~]# at now +1min
warning: commands will be executed using /bin/sh
at> touch /root/sam1.txt
at> <EOT>
job 9 at Wed Jun 12 06:08:00 2024
[root@centos9vm ~]# atq
9 Wed Jun 12 06:08:00 2024 a root
[root@centos9vm ~]# ls -l | grep sam1
[root@centos9vm ~]# ls -l | grep sam1
-rw-r–r–. 1 root root 0 Jun 12 06:08 sam1.txt
The same command can be executed in another method
[root@centos9vm ~]# echo “touch /root/sam2.txt” | at now +1min
warning: commands will be executed using /bin/sh
job 12 at Wed Jun 12 06:12:00 2024
[root@centos9vm ~]# atq
12 Wed Jun 12 06:12:00 2024 a root
[root@centos9vm ~]# ls -l | grep sam2
[root@centos9vm ~]# date
Wed Jun 12 06:12:01 AM IST 2024
[root@centos9vm ~]# ls -l | grep sam2
-rw-r–r–. 1 root root 0 Jun 12 06:12 sam2.txt
=== ===
The common commands used are as follows:
- at now +1min
- at noon
- at midnight
- at 13:30
- at 14:30 2027-9-25
Command to see the at commands yet to run is as follows:
[root@centos9vm ~]# atq
14 Wed Jun 12 06:19:00 2024 a root
This information is also available in /var/spool/at along with the commands associated
== === =
Command to see details of a job in queue
[root@centos9vm ~]# at -c 14
Command to remove a job in queue
[root@centos9vm ~]# atrm 14
[root@centos9vm ~]# atq
[root@centos9vm ~]#
We can deny list of users from executing jobs using “at” command. The names if these users needs to be listed in
- /etc/at.deny