A small tool for deploying crontab into your system.
It's useful if you want to deploy some crontab scripts into your system when you deploy your software that contains some extra crontab scripts.
pip install deploycron
There's only one function in the package now,
def deploycron(filename="", content="", override=False):
Install crontabs into the system if it's not installed.
This will not remove the other crontabs installed in the system if not specified
as override. It just merge the new one with the existing one.
If you providefilename
, then will install the crontabs in that file
otherwise install crontabs specified in content
filename
- file contains crontab, one crontab for a line
content
- string that contains crontab, one crontab for a line
override
- override the origin crontab
Example:
from deploycron import deploycron
# specify a filenmae
deploycron(filename="/tmp/youcrontab.tab")
# or just specify crontab content
deploycron(content="* * * * * echo hello > /tmp/hello")
# if you want to overwrite the existing crontab, set `override` to True
deploycron(content="* * * * * echo hello > /tmp/hello", override=True)
Only support in unix-like system, eg. Linux/Mac
- Monklof (monklof@gmail.com)
MIT