https://github.com/cedadev/crontamer
Cron wrapper
https://github.com/cedadev/crontamer
Last synced: about 1 year ago
JSON representation
Cron wrapper
- Host: GitHub
- URL: https://github.com/cedadev/crontamer
- Owner: cedadev
- Created: 2016-12-05T11:00:48.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-04-18T08:46:54.000Z (about 2 years ago)
- Last Synced: 2024-09-22T00:05:36.456Z (over 1 year ago)
- Language: Python
- Size: 25.4 KB
- Stars: 3
- Watchers: 9
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Crontamer
A wrapper script for cron to stop multiple process instances starting. Also times out after 12 hours (default)
and emails on error.
## Installation
This is simple python script, put it somewhere in your path.
For system-wide installation (or if you are using a virtual env), you can
use `pip install .` after `cd` to this directory. You may wish to first
install pip and the Python package dependencies via your package manager,
and also to create a symlink in `/usr/bin` where it will be in the `PATH`
used by cron jobs, e.g.:
```
yum install python3-pip python3-psutil python3-docopt
pip install .
ln -s /usr/local/bin/crontamer /usr/bin
```
## Usage
Usage: crontamer.py [options] 'my_script -opt1 -opt2 arg1 arg2'
Wrapper script for cron jobs enabling locking, timeouts and email of failures.
The wrapped commands should be a single quoted string so that any shell
expansion and option parsing happens within the wrapped subprocess.
Options:
-h, --help show this help message and exit
-t HOURS, --timeout=HOURS
set timeout for jobs in hours [default: 12.0]
-l Sets the process locking so that another instance of
this job will not start [default]
-u Sets the process locking so that another instance of
this job can start
-e EMAIL, --email=EMAIL
email address to sent to on script fail or timeout
-v verbose output set
Examples
$ crontamer
$ crontamer.py -v -t 0.001 'echo START...;sleep 20 ;echo ...END'
Make Lock for process 16875 file: /tmp/crontamer.bf3743cba1a799ee03400690ff8b2a38
Starting process for 'echo START...;sleep 20 ;echo ...END'
START...
Killed on timeout!
Process ended Mon Aug 1 11:53:39 2016