cronwrap: Another cure for Cron's email problem![]() cronwrap is a simple Python script that can improve your cron jobs. It offers following features:
Source: cronwrap on github Installing cronwrap$ sudo easy_install cronwrap $ cronwrap -h UsageWill email a timeout alert to cron@my_domain.com: $ cronwrap -c "sleep 2" -t "1s" -e cron@my_domain.com Will email an error alert to cron@my_domain.com, since the command crashes: $ cronwrap -c "blah" -e cron@my_domain.com Will not email any reports since it's a successful run: $ cronwrap -c "ls" -e cron@my_domain.com Will email a successful report to cron@my_domain.com, because verbosity is turned on: $ cronwrap -c "ls" -e cron@my_domain.com -v Help and usage:
$ cronwrap -h
usage: cronwrap [-h] [-c CMD] [-e EMAILS] [-t TIME] [-v [VERBOSE]]
A cron job wrapper that wraps jobs and enables better error reproting and
command timeouts.
optional arguments:
-h, --help show this help message and exit
-c CMD, --cmd CMD Run a command. Could be `cronwrap -c "ls -la"`.
-e EMAILS, --emails EMAILS
Email following users if the command crashes or
exceeds timeout. Could be `cronwrap -e
"johndoe@mail.com, marcy@mail.com"`. Uses system's
`mail` to send emails. If no command (cmd) is set a
test email is sent.
-t TIME, --time TIME Set the maxium running time.If this time is passed an
alert email will be sent.The command will keep running
even if maxium running time is exceeded.The default is
1 hour `-t 1h`. Possible values include: `-t 2h`,`-t
2m`, `-t 30s`.
-v [VERBOSE], --verbose [VERBOSE]
Will send an email / print to stdout on succefull run.
Hope you find it useful and happy hacking! PS:I would like to say happy Whyday! Time flies so fast and I can't believe it's one year since he left. I wrote about him on 21. august 2009 ( _why's way of living ). His influence lives on even if he is gone — a true legend!
Announcements
·
Code
·
Code improvement
·
Python
•
19. Aug 2010
|
|