Here's a little program I wrote to solve a small problem I've been having with cron. Say one has in one's crontab the following line:
0 0 * * * /usr/bin/rsync -avz dir1/ /backup/dir1/
This backs up
dir1 to a backup directory.
rsync, however, creates a lot of output (especially with the
-v switch)... and cron sends that output to your email, so every day, you'll be getting an email message from cron with the results of the backup. To avoid this, most people simply redirect the output to
/dev/null. What if I do actually want to see the output though, just not in my inbox?
crarchive is a little script that will log the results of cron runs in a folder, gzip old logs, and delete really old logs automatically. It allows the output of commands run in cron to be saved and archived, but without clogging up your inbox. Eventually, it will also support more customizability, but because this is only the first release, it has the following limitations...
- Maximum one run per day
- Logs to
- Gzips logs that are one day old, deletes logs that are thirty (unchangeable)
crarchive will, however, email you if something goes wrong (unfortunately, again, error checking in this early version is primitive). Here's a usage example with the crontab from earlier (assuming we've installed
0 0 * * * /usr/bin/rsync -avz dir1/ /backup/dir1/ | /usr/bin/crarchive.py rsync-dir1
rsync-dir1 is an arbitrary name that you choose.