Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

Linux 排程利器:at 單次執行與 crontab 循環執行完整語法指南

編輯:關於 Linux

at:一次性排程

基本流程

at 時間
輸入指令
Ctrl+D 結束

時間格式

  • 數字:03:45、05:25pm
  • 關鍵字:midnight(00:00)、noon(12:00)、now
  • 日期:today、tomorrow、Jan 2 2025、mon
  • 增量:+ 1 week、+ 3 days

範例

at 6pm
at noon tomorrow
at 02:00am + 1 week
at 6pm Jan 2 2025

權限控制

/usr/lib/cron/at.allow、/usr/lib/cron/at.deny

刪除工作

at -r 作業編號

crontab:週期性排程

編輯

crontab -e

時間欄位

分 時 日 月 週  指令

範例

0 4 * * 2,5 /usr/bin/wall < /etc/motd           # 每週二五 04:00 廣播
*/2 12-14 * 3-6,9-12 1-5 /path/to/script.sh     # 3-6月、9-12月 平日 12-14點 每2分執行

系統層級設定檔

/etc/crontab

結語

at 適合臨時一次性任務,crontab 適合固定週期維運,兩者互補構成完整排程體系。

Copyright © Windows教程網 All Rights Reserved