Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Unix知識 >> Unix基礎知識

Ubuntu 上使用 crontab 建立定時任務

cron 是 Unix/Linux 常見的定時任務機制。Ubuntu 中可使用使用者級 crontab,也可編輯系統級設定。

使用者 crontab

crontab -e
# m h dom mon dow command
3 * * * * /home/meng/hello.sh

上述範例表示每小時的第 3 分鐘執行 hello.sh。修改後可重新啟動 cron 服務,並觀察結果。

系統 crontab

系統檔案通常位於 /etc/crontab,格式比使用者 crontab 多出 user 欄位,可指定執行身分。

3 * * * * root /home/meng/hello.sh
Copyright © Linux教程網 All Rights Reserved