How do I create a crontab through a script

前端 未结 12 1074
再見小時候
再見小時候 2020-11-28 01:36

I need to add a cron job thru a script I run to set up a server. I am currently using Ubuntu. I can use crontab -e but that will open an editor to edit the curr

12条回答
  •  猫巷女王i
    2020-11-28 02:20

    I have written a crontab deploy tool in python: https://github.com/monklof/deploycron

    pip install deploycron
    

    Install your crontab is very easy, this will merge the crontab into the system's existing crontab.

    from deploycron import deploycron
    deploycron(content="* * * * * echo hello > /tmp/hello")
    

提交回复
热议问题