API Guide

Model Class

class crontab_py.crontab.Crontab

Crontab class to manage crontab jobs.

example:

from crontab_py import Crontab

ct = Crontab()

ct.add_job(

cmd=”echo ‘hello world’”, frequency=”* * * * *”, path_to_log=”/tmp/crontab.log”, id=”my_job”, description=”my job”

)

add_job(cmd: str, frequency: str, path_to_log: str = None, id: str = None, description: str = None) None

Add a job to crontab

Args:

cmd (str): cmd to execute frequency (str): crontab frequency path_to_log (str, optional): path to log file if it needed. Defaults to None. id (str, optional): unic identifier for the job. Defaults to None. description (str, optional): description of the job. Defaults to None.

add_pyjob(path: str, frequency: str, path_to_log: str = None, path_requirements: str = None, id: str = None, description: str = None, *args, **kwargs) None

add a python job to crontab

Args:

path (str): path to python script frequency (str): crontab frequency path_to_log (str, optional): path to log file if it needed. Defaults to None. path_requirements (str, optional): path to pip install - r, if exist generate a venv to execute the script. Defaults to None. id (str, optional): unic identifier for the job. Defaults to None. description (str, optional): description of the job. Defaults to None.

remove_all() None

Remove all jobs from crontab

remove_job(id: str) None

remove a job from crontab by id not working yet

Args:

id (str): unic identifier for the job