atbatchatqatrmcron- /etc/crontab
- Example of job definition:
- .———————— minute (0 - 59)
- | .——————- hour (0 - 23)
- | | .————— day of month (1 - 31)
- | | | .———- month (1 - 12) OR jan,feb,mar,apr …
- | | | | .—— day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
- | | | | |
- * user-name command to be executed
at batch atq atrm
安装 at
at 用法
at [-q queue] [-f file] [-mMlv] timespec...# -q 默认为 a# -f 执行 file 里的指令
at 日期格式
- now:
at now + n UNIT- n: 整数
- UNIT: minutes/hours/days/weeks
at TIME- TIME: HH:MM[am|pm] [MMDD[CC]YY | DD.MM.[CC]YY | [CC]YY-MM-DD]
- SPECIAL TIME: TIME tomorrow/midnight/noon/teatime(4:00 p.m.)
at TIME + n UNIT
<a name="g0ozO"></a>### `batch````bash# 当系统负荷小于某值时执行任务batch # -q 默认为 bat -b # 等价于 batch
atq
# 查看任务队列中的任务atq
atrm
# 移除任务atrm TASK_NUMBER...
/etc/at.allow /etc/at.deny
one username per line
cron
System Jobs
- /etc/cron.allow
- /etc/cron.deny
- /etc/cron.hourly/
- /etc/cron.daily/
- /etc/cron.weekly/
- /etc/cron.monthly/
- /etc/crontab
```bash/etc/crontab
SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
Example of job definition:
.———————— minute (0 - 59)
| .——————- hour (0 - 23)
| | .————— day of month (1 - 31)
| | | .———- month (1 - 12) OR jan,feb,mar,apr …
| | | | .—— day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
| | | | |
* user-name command to be executed
17 root cd / && run-parts —report /etc/cron.hourly 25 6 root test -x /usr/sbin/anacron || ( cd / && run-parts —report /etc/cron.daily ) 47 6 7 root test -x /usr/sbin/anacron || ( cd / && run-parts —report /etc/cron.weekly ) 52 6 1 * root test -x /usr/sbin/anacron || ( cd / && run-parts —report /etc/cron.monthly )
`run-parts` : run scripts or programs in a **directory**.<a name="Eraul"></a>### User Jobs`crontab -e` 编辑用户的 crontab,即 /var/spool/con/crontabs/USERNAME<br />`crontab -l` 列出用户的 crontab 里的内容<br />`crontab -r` 删除用户的 crontab 里的内容<a name="dj2tV"></a>## rtcwake```bash# rtcwake -m [type of suspend] [-s NUM_OF_SECONDS | -t time_t | --date timestamp]# -m# standby —The computer is put into standby mode, which saves some power over running normally but not nearly as much as the other options. This is the default setting and will be used if you omit -m .# disk —(hibernate) The current state of the computer is written to disk, and the computer is powered off.# mem —(sleep) The current state of the computer is written to RAM, and the computer is put into a low-power state, using just enough power to keep the memory preserved.# no —The computer is not suspended immediately. Only the wakeup time is set. This allows you to continue working; you have to remember to put the computer to sleep manually.# off —The computer is turned off completely. Wake will not work with this setting for everyone and is not officially supported, but it does work with some computers. It is included here for those who like to live dangerously.
- rtc: real time clock
rtcwake ... && cmd1在系统被唤醒后执行 cmd1
