Skip to main content

a little extension to cron with timezone support (latest version is 1.0.3)

Project description

crone: A little extension to cron

INSTALL

1. Download the source distribution
2. Untar/unzip the source distribution
3. Run python setup.py install
*** the module will appear as an editable source file in site-packages.

or

1. Run easy_install crone
*** the module will appear as an uneditable binary file in site-packages.

USAGE

Like cron, but you have more flexibility to scope down the time you want your
commands executed. First of all, you have to ask cron to run crone.py every
minute with something like:

* * * * * python -m crone -p cronetab > crone.log 2>&1

In your cronetab file, you specify crone (cron with extension) tasks, like:

* * * * * * * * * echo "Hello World!"
| | | |
| | | --> timezone, e.g. Australia/Melbourne and UTC (* = UTC)
| | --> interval from begin, e.g. 7d and 14d (* = 1d)
| --> end period, e.g. 2011-11-11T11:11:11 (* = 2099-12-31T23:59:59)
--> begin period, e.g. 2011-11-11T11:11:11 (* = 2000-01-01T00:00:00)

The first five conditions are exactly like cron. However, not all formats are
supported. At the moment, something like 1, 1,2,3, 0-10, * and */2, including
all of them combined like 1,2,*,*/5,2-9 should work. The last fours are begin,
end, interval and timezone, and subject to this extension a command is executed
iff the current time at the given timezone is within the period, i.e. begin to
end inclusively, and falls within the interval -- note that only day intervals
is supported at the moment and the format of time is YYYY-mm-ddTHH:MM:SS.

More examples of cronetab entries are shown below. Note that an entry prefixed
with # will never ever be executed.

*/5 */1 * * * * * * Australia/Melbourne echo "Hello Melbourne!"
* * * * * 2011-11-15T00:00:00 * 1d Australia/Melbourne echo "Hello Melbourne!"
#* * * * * * * * * echo "Hello Melbourne!"

To see all possible arguments, run python -m crone -h and you will see:

Usage: crone.pyc [options]

Options:
-h, --help show this help message and exit
-p PATH, --path=PATH path to the crontab file (required)
-t TZPATH, --tzpath=TZPATH
path to the timezone directory (default is
/usr/share/zoneinfo)

You use -p to indicate the absolute path to your cronetab file, and you use -t
to indicate the absolute path to the directory that contains timezone data. On
my machine, it is /usr/share/zoneinfo, so it is default in crone.

DEPENDENCIES

pyparsing (easy_install pyparsing)
dateutil (easy_install python-dateutil)

CONTACT

If you have suggestions, reqeusts, etc, please feel free to create an issue in
GitHub. Pull requests are also very much welcome.

RELEASE NOTE

1.0.0: Initial release.
1.0.1: Add more information, instruction, etc.
1.0.2: Fix issues #1-#2 (mostly adding unit testing).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crone-1.0.2.tar.gz (4.6 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page