at
进程与系统
用法
at <time> (then type the command, Ctrl+D to finish)在你指定的时刻只运行命令一次;需要 atd 守护进程在跑(很多发行版根本没装),而且输出是发邮件给你,不会打印到屏幕。
常用选项
| 选项 | 含义 |
|---|---|
| at 15:00 / at 3pm tomorrow | Absolute times, in many spellings. |
| at now + 10 minutes | Relative times: minutes, hours, days, weeks. |
| -f <file> | Run a script file instead of typing the command. |
| atq | List the jobs you have queued (same as at -l). |
| atrm <n> | Delete queued job number n (same as at -r). |
示例
echo "systemctl restart nginx" | sudo at now + 5 minutesOne restart, five minutes from now.
at -f deploy.sh 02:00Run a script once at 2am.
atqCheck what is still queued.
看什么在跑、什么在吃机器。先弄清是什么,再决定杀不杀。
怎么看
- 方括号 [ ] 表示这部分可以不写。
- 省略号 … 表示可以写多个。
- 选项区分大小写——有些命令里 -r 和 -R 不是一回事。
常见问题
Q. at 是做什么的?
在你指定的时刻只运行命令一次;需要 atd 守护进程在跑(很多发行版根本没装),而且输出是发邮件给你,不会打印到屏幕。
Q. 怎么写?
at <time> (then type the command, Ctrl+D to finish) —— 方括号表示可以省略的部分。
Q. 值得记的选项有几个?
这里列了 5 个,完整列表在 man at。这条命令属于进程与系统。
相关命令
man 手册: man at