How to run a cron job inside a docker container?

前端 未结 20 1595
無奈伤痛
無奈伤痛 2020-11-22 05:36

I am trying to run a cronjob inside a docker container that invokes a shell script.

Yesterday I have been searching all over the web and stack overflow, but I could

20条回答
  •  没有蜡笔的小新
    2020-11-22 06:20

    Cron jobs are stored in /var/spool/cron/crontabs (Common place in all distros I Know). BTW, You can create a cron tab in bash using something like that:

    crontab -l > cronexample
    echo "00 09 * * 1-5 echo hello" >> cronexample
    crontab cronexample
    rm cronexample
    

    This will create a temporary file with cron task, then program it using crontab. Last line remove temporary file.

提交回复
热议问题