To timetable a command or script to run at some particular time, the at command is ideal and provides many options for specifying the time you want it to operate. It will established the job up to be run every time you specify, and you can see the scheduled jobs or even improve your thoughts and terminate one particular of them as you see in shape.
The at command differs from cron in that it sets up a command or script to operate only after, whilst cron will allow you to established up commands or scripts to be operate on a specified schedule – no matter whether each and every day, the moment a week, a few moments a thirty day period or even just once a calendar year.
at command syntax
Making use of the at command is rather simple, while it has a large amount of alternatives, specifically on how you specify the time a activity should be operate. If you specify a time like shown below, the job will be established up to be run the upcoming time you attain 15:27 (3:27 PM), whether that’s right now or tomorrow.
$ at 15:27 warning: commands will be executed utilizing /bin/sh at Wed Mar 15 15:27:00 2023 at> echo "It is effective!" > /tmp/test at>
task 5 at Wed Mar 15 15:27:00 2023
Close the at command by urgent ^D.
In the subsequent illustration, the command is set to operate the adhering to day at the time specified.
$ at 12:34 tomorrow warning: instructions will be executed making use of /bin/sh at Wed Mar 15 12:34:00 2023 at> echo 1234 >> /tmp/wow at>
career 6 at Wed Mar 15 12:34:00 2023
You can specify the time of working day in either of two formats. If you question to have a command operate at 11:11, it will be run at 11:11 AM. To specify it to run at 11:11 PM, use 23:11 or 11:11pm as the time.
Dates can be also specified in any of these formats:
MMDD[CC]YY MM/DD/[CC]YY DD.MM.[CC]YY [CC]YY-MM-DD
You can also specify a job on some individual day by specifying a weekday (e.g., Sunday).
$ at midday Wednesday warning: commands will be executed making use of /bin/sh at Wed Mar 15 12:00:00 2023 at> date >> /tmp/test at>
occupation 7 at Wed Mar 15 12:00:00 2023
Listing at positions
To record the tasks scheduled with the at command, use the atq (at queue) command.
$ atq 5 Wed Mar 15 15:27:00 2023 a shs 6 Wed Mar 15 12:34:00 2023 a shs 7 Wed Mar 15 12:00:00 2023 a shs
The command shows the employment ready to be run, but not the tasks they will be operating. The facts only include the career figures, the instances they will operate and the person who extra them. Only root is capable to watch all of the scheduled duties. Other people will see only their own.
Deleting at work
You can cancel a scheduled career with the atrm command.
$ atrm 5 $ atq 6 Wed Mar 15 12:34:00 2023 a shs 7 Wed Mar 15 12:00:00 2023 a shs
The command beneath delivers a list of commands involved with the at command.
$ sudo dnf repoquery -l at | grep bin [sudo] password for shs: Very last metadata expiration examine: 1:16:38 back on Fri 10 Mar 2023 01:40:19 PM EST. /usr/bin/at /usr/bin/atq /usr/bin/atrm /usr/bin/batch /usr/sbin/atd /usr/sbin/atrun /usr/bin/a
Consistently scheduled jobs should be set up employing the cron command, but to run some certain endeavor at some certain time (no repeats), the at command is versatile and effortless..