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