Skip to content

panuph/crone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 concurrently (default is 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 execute commands in
concurrent manner.

DEPENDENCIES

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

CONTACT

If you have suggestions, requests, 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).

About

A little extension to cron

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages