Croncape wraps commands run as cron jobs to send emails only when an error or a timeout has occurred.
Out of the box, crontab can send an email when a job generates output. But a command is not necessarily unsuccessful "just" because it used the standard or error output. Checking the exit code would be better, but that's not how crontab was standardized.
Croncape takes a different approach by wrapping your commands to only send an email when the command returns a non-zero exit code.
Croncape plays well with crontab as it never outputs anything except when an issue occurs in Croncape itself (like a misconfiguration for instance), in which case crontab would send you an email.
Download the binaries or go get github.com/sensiocloud/croncape
.
When adding a command in crontab, wrap it with Croncape:
0 6 * * * croncape -e "sysadmins@example.com" -c "ls -lsa"
That's it!
You can also send emails to more than one user by separating emails with a comma:
0 6 * * * croncape -e "sysadmins@example.com,sys@foo.org" -c "ls -lsa"
Besides sending emails, croncape can also kill the run command after a given timeout, via the -t
flag (by default, the limit is 1 hour):
0 6 * * * croncape -e "sysadmins@example.com" -t 2h -c "ls -lsa"
If you want to send emails even when commands are successful, use the -v
flag (useful for testing).
Use the -h
flag to display the full help message.
Croncape is very similar to cronwrap, with some differences:
No dependencies (cronwrap is written in Python);
Kills a command on a timeout (cronwrap just reports that the command took more time to execute);
Tries to use sendmail
or mail
depending on availability (cronwrap only works with sendmail
).
For a simpler alternative, have a look at cronic.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4