❑ at : This is a utility to run scheduled jobs once. It uses /bin/sh.
❑ How to use
❍ Check scheduled jobs : at -l, atq
❍ Job waiting queues range from a to z and A to Z. The closer to a, the higher the priority.
❍ Pending jobs are stored as the file format in the /var/spool/at directory.
❍ e.g. at 13:50 → date > /dev/pts/0
Time format | Description |
20:30 | 0~23H hour range is possible. |
11:00 PM | AM/PM format is possible. |
Feb 6 2015 17:00 | [Month] [Date] [Year] [Time] |
061119 06-11-19 06.11.19 | [Month] [Date] [Year] |
now + 10min | 10 minutes after from current time. |
❑ Crontab : This is a utility to run scheduled jobs periodically.
❑ How to use
❍ Check scheduled jobs : crontab -l
* The edited crontab contents are saved as the file format in /var/spool/cron/[Login name].
❍ Edit scheduled jobs : crontab -e
* When the crontab -e command is executed, a temporary file of the form crontab.* is created in the / tmp directory, and the vi editor is executed for editing this temporary file.
❍ Remove all schedules jobs : crontab -r
* Normally for preventing mistakes, e option is used rather than the r option when removing unnecessary contents.
❍ Job format : [Minute] [Hour] [Day of month] [Month] [Day of week] [Command]
❍ crontab [Crontab file] : Crontab also can be used by register crontab format files.
❍ e.g. Save the result of ps -ef to /tmp/rst on the first Friday of every month at 9:00 am and 5:00 pm.
→ 0 9,17 1-7 * 5 ps -ef > /tmp/rst
Special character | Description |
* | Always. |
- | Range.
(1-5 = 1,2,3,4,5)
|
, | Multiple values. |
/ | Repetition interval.
(*/5 * * * * = every 5 minutes)
|
❑ "/etc/cron.deny" and "/etc/cron.allow"
* Depending on the type of Linux, there may or may not be this two files.
❍ If both exists : Only users registered in cron.allow can use cron.
❍ If only cron.deny exists : Only users unregistered in cron.deny can use cron.
❍ if both don't exists : Only root can use cron.
Check environment | |||
O S | CentOS 7.4.1708(64bit) | CPU | Intel i7-4710MQ 2.50GHz |
SHELL | GNU bash (4.3.46(2)) | RAM | 1 GB |