14

Mac OS 執行 crontab (例行性工作排程)

 2 years ago
source link: https://blog.niclin.tw/2018/04/08/mac-os-%E5%9F%B7%E8%A1%8C-crontab-%E4%BE%8B%E8%A1%8C%E6%80%A7%E5%B7%A5%E4%BD%9C%E6%8E%92%E7%A8%8B/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Nic Lin's Blog

喜歡在地上滾的工程師

新建一個來兼看 crontab 是否順利執行的文件

touch /tmp/crontab_log.txt

設定定時任務

crontab -e

0/5 * * * * /bin/date "+%Y-%m-%d %H:%M:%S" >> /tmp/crontab_log.txt

:wq 存檔後退出,會看到

crontab: installing new crontab

接著我們來看每分鐘是否會將當前時間記錄到該文件裡

tail -f /tmp/crontab_log.txt

如果有出現就代表成功,可以在 mac 上執行定時任務。

如果沒有的話參考 在MAC OS X上如何启用crontab?

如果對於 cron 的時間設定不熟悉也可以參考 crontab.guru


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK