Escolar Documentos
Profissional Documentos
Cultura Documentos
1/11
1/2/2018 One Time Task Scheduling using at Command in Linux –
# at 9:00 AM
at> sh backup.sh
at> ^d
job 3 at 2013-03-23 09:00
https://tecadmin.net/one-time-task-scheduling-using-at-commad-in-linux/ 2/11
1/2/2018 One Time Task Scheduling using at Command in Linux – TecAdmin
# atq
Fields description:
First filed: job id
Hosted@DigitalOcean
# atrm 3
# atq
5
2013-03-23 10:00 a rahul
1
2013-03-23 12:00 a root
# at -c 5
Examples of at Command:
Example 1: Schedule task at coming 10:00 AM.
3/11
1/2/2018 One Time Task Scheduling using at Command in Linux – TecAdmin
# at 10:00 AM
# at 10:00 AM Sun
Hosted@DigitalOcean
# at 10:00 AM July 25
# at 10:00 AM 6/22/2015
# at 10:00 AM 6.22.2015
# at 10:00 AM tomorrow
# at 10:00 AM tomorrow
# at now + 1 hour
https://tecadmin.net/one-time-task-scheduling-using-at-commad-in-linux/ 4/11
1/2/2018 One Time Task Scheduling using at Command in Linux – TecAdmin
# at now + 30 minutes
# at now + 1 week
# at now + 2 weeks
# at now + 1 year
# at now + 2 years
# at midnight
5/11
1/2/2018 One Time Task Scheduling using at Command in Linux – TecAdmin
I just wanted to extend it a bit with some useful additions. 1) You can use - f
option to point “at” to the script you need
to run:
at - f /path/to/the/script time_spec
2) One can use “at” to start a process in background without nohup, etc.
As easy as
at - f /a /c om m and now
or
echo “/a/command” | at now
3) You can use “at” to run a c om m a n d repeatedly, but unlike cron you can use “
at” to run c om m ands with some period between runs, for example after 3
minutes after previous run was completed. This allow you to avoid various
checks preventing next run to start before previous is finished.
Moreover you can define this period as random value. Examples:
The script (lets nam e it /home/user1/at_run.sh):
————————————-
#!/bin/bash
/the/command/you/need
# fixed period between runs
period=3
# or random period. RANDOM is a bash’s random number from 0 to 32767
period=$[ ($RANDOM % 20) + 15 ]
at - f /home/user1/at_run.sh now + $period minutes
————————————-
run /home/user1/at_run.sh and all next runs will be scheduled
automatically, so your
/the/command/you/need will run repeatedly forever. Sure, you can break the
next run with atq/atrm.
6/11