Supercron

Intelligent interface to cron in UNIX systems

Download as .zip Download as .tar.gz View on GitHub

SuperCron

Intelligent interface to cron in UNIX systems.

Installation

SuperCron can run on Python 2.7 or Python 3.3+.

Run pip install supercron.

Alternatively, you can clone the repo, then run cd supercron; python setup.py install from inside the SuperCron repo folder.

SuperCron vs classical crontab

SuperCron is based on crontab, while providing the following additional advantages:

Usage

SuperCron can run either in interactive mode or non-interactive mode.

Interactive mode:

Run supercron without any arguments to start interactive mode. You will prompted to choose an action, and then to enter action parameters (like name, command and repetition) if any.

Non-interactive mode:

In non-interactive mode, one of the following options can be used after the command name supercron.

Additionally, one of the following subcommands can be used: add, delete, enable, disable, search, clear, trigger.

Subcommand add

Subcommand rename

Subcommands delete, enable and disable

Subcommand search

Subcommand clear

Note: this subcommand will only clear SuperCron jobs from user's crontab.

Subcommand trigger

Triggers

Triggers can take one of 2 forms:

ACTION is the action applied on the enabled state of the triggered job and it can be on, off or toggle.

NAME is the name of the triggering job.

STATE is the triggering state of the triggering job, and it can be enabled, disabled, toggled, added or deleted.

Using action toggle means to enable the triggered job if it was disabled, and to disable it if it was enabled.

State toggled activates the trigger when the triggering job is enabled or disabled.

Note that when a job is renamed from name1 to name2, it means activating triggers that end with if name1 is deleted and triggers that end with if name2 is added, since a rename is considered a deletion of the old job name and an addition of the new job name.

Examples

supercron add -c "date +%j >> log_file" -r "every 2 days" log_dates
supercron add -c "scp -r /path1 user@server:/path2" -r "at 11:50 pm on mondays" backup_server
supercron rename log_dates log_all_dates
supercron delete log_dates
supercron enable log_dates
supercron disable log_dates
supercron search log_dates
supercron search @supercron
supercron search @all
supercron clear
supercon trigger -t "on if log_months is off" log_days
supercron trigger -t none log_days

Repetition sentences

Repetition sentences are provided in a supercron add command directly after the -r or --repetition option.

Examples of accepted repetition sentences (case insensitive):

Repetition sentences can also be any (unsorted) logical mix of the above. For example: