Skip to main content

a little extension to cron with timezone support

Project description

crone: a little extension to cron with timezone support

OVERVIEW

Like cron, but you can further indicate the timezone, the period and interval
to run a command (tested on python 2.6 but should be fine to run with older
python release). See USAGE for more detailed information.

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 (calculated from begin) and timezone conditions. Subject to this
extension a command is executed iff the current time in the given timezone is
within the period, i.e. begin to end (specified in format YYYY-mm-ddTHH:MM:SS)
inclusively, and falls within the interval -- either day e.g. 7d, hour e.g. 7h
or mintue e.g. 7m.

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 view all possible arguments, you run python -m crone -h and will see things
similar to below:

Usage: crone.py [options]

Options:
-h, --help show this help message and exit
-p PATH, --path=PATH path to the cronetab file (default is ~/.cronetab)
-t TZPATH, --tzpath=TZPATH
path to the timezone directory (default is
/usr/share/zoneinfo)
--concurrent run commands concurrentl (default if False)

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. See
http://www.linuxsa.org.au/tips/time.html for information about this topic. On
my machine, the directory is /usr/share/zoneinfo, so it is default in crone. By
default, crone executes commands in order, waiting for each to complete before
executing the next. If you flag --concurrent, crone will executes commands in
concurrent manner.

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: Resolve issues #1 and #2 (mostly about unit testing).
1.0.3: Resolve issues #3, #5, #6 and #7 (bug fixes and improvements).

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.3.tar.gz (5.3 kB view details)

Uploaded Source

File details

Details for the file crone-1.0.3.tar.gz.

File metadata

  • Download URL: crone-1.0.3.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for crone-1.0.3.tar.gz
Algorithm Hash digest
SHA256 1ce723965ebbfc9fa1c731daed1821784d112619ab6fbdde812264b0727bfd56
MD5 d9fb99f0632e9b6d29fa2cf9a4ebda0a
BLAKE2b-256 879a4f4c780c2a1c84671d638b03a9151889d39d7a0c9b064b85e35e1fdb7a0f

See more details on using hashes here.

Supported by

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