Plan Definition

This part shows how to initialize one plan object. One plan object takes parameters name, path, environment, output and user, for more details check out Plan. Path, environment and output are the same with Job Definition, they are used to set global parameters for all jobs registered on this plan object. If a job does not set one parameter, and a global parameter is set, the global one will be used.


The name of one plan object. Should be passed as the first parameter.


If you want to run crontab command with a certain user, remember to set this parameter.

Environment Variable

New in version 0.5.

Sometimes you need to set environment variable in the crontab. For example you want to change crontab email settings, you can do it as simple like this:

cron = Plan()
cron.env('MAILTO', '')
cron.command('command', every='')'check')

For more details check out env().


Maybe you want to do some bootstrap work before you run your plan object, like you used one third party library in your Python script, you need to install it before running. You can do that as simple like this:

cron = Plan()
cron.bootstrap('pip install requests')
cron.bootstrap(['pip install Sphinx', 'sphinx-quickstart'])
cron.script('', every='', path='/tmp')'check')

Bootstrap takes one command or a list of commands, for more details check out bootstrap().


One Plan object should be a group of cron jobs. The name of the plan object should be unique so that this object can be distinguished from another object. Now you can have multiple plan object around and run it with update run_type, only the corresponding content block will be renewed in the cronfile, for more details go to Run Types part.

Table Of Contents

Related Topics

This Page

Fork me on GitHub