容器內運行cron

有時候會需要在容器內運行特定時間的腳本就會透過 crontab ,但alpine版本的容器無啟用該套件,本篇紀錄了下啟動方式

mkdir -p /data/var/logs/crontab
crond -b -l 2 -L /data/var/logs/crontab/crond.log

參數說明:
  -b:以背景模式執行(background)。
  -l 2:日誌等級設為 2。BusyBox crond 數字越小越詳細,除錯時適用。
  -L /data/var/logs/crontab/crond.log:把 cron daemon 的日誌寫到這個檔案,而不是送到 syslog。