In this article, we are going to use, at command in Linux.
at command is known for a
one-time job scheduler. This is very useful when you want a job to run once. It reads commands from standard input or script/file, which can be executed later once. But we can’t use at command for any recurring tasks. For recurring tasks, we use
crontab in Linux.
The benefits of at, at command in linux
- Taking a one-time backup.
- Scheduling for system shutdown for a specific time.
- Sending any remainder email for a specific time.
- Firing any command once at any particular time.
Installation of at
Installing on CentOS or RHEL,
yum install at
Installing on Fedora
If you are installing on Fedora then you can use the below command.
dnf install at
Installing on Debian or Ubuntu
There is a different command to install on Debian or Ubuntu. Ubuntu is generally based on Debian. You can find the below command useful for this.
apt install at
Installing on Arch
Arch Linux has another command for this installation.
pacman -S at
Starting the service for at and enabling on startup
There is the command to start and enable the service to start on the next reboot automatically.
systemctl start atd
systemctl enable atd
Commands used with at
at – execute commands at a specified time.
atq – lists the pending jobs of users.
atrm – delete jobs by their job number.
Schedule a job using the at command from Terminal
1: To run a command exact one minute from now
at now + 1 minutes at> echo "Welcome to the Linux" > welcome.txt at> <EOT> job 3 at Sun Jan 19 22:27:00 2020
2: If you want to run a command at 10 AM 2 days from now then the command will look like the below,
at 10am + 2 days
3: To schedule a task at 9:00 AM.
at 9:00 AM
4: If you want to schedule a task at 09:00 AM on the coming Sunday.
at 09:00 AM Sun
5: Schedule a task at 10:00 AM on the coming 20th Jan.
at 10:00 AM Jan 20
6: Schedule a task at 09:00 AM on the coming 20th of Jan 2020.
at 09:00 AM 1/20/2020
at 09:00 AM 1.20.2020
7: Schedule task at 09:00 AM on the same date next month.
at 09:00 AM next month
8: Schedule task at 09:00 AM tomorrow.
at 09:00 AM tomorrow
9: Schedule tasks to execute just after 1 hour.
at now + 1 hour
- To check the current jobs, only type
- If you want to delete any job, type
- To check the content of the scheduled job, type
at -c job_id
Scheduling to run a script
If you want to run a script then you can use
In this tutorial, we learn about at command, which is used for scheduling the task for one time run. I hope you understand, but if you have any questions, you can ask in the comment section.
You may like to read