This logging wrapper, written in perl, has a few improvements on the previous one:
- Command line option: “–skip-repeats” to prevent saving results identical to previous run.
- Command line option: “–path-head” for specification of top level directory for results. Defaults to command name.
- Command line option: “–path-resolution” for specification of resolution of directory creation for output files. Defaults to “year”
- Pushes results to remote git repository.
- Partitions the output files by year directory. The github web interface complains about more than 1000 files in a directory.
- Implemented in two files: loggedcron.pl and gitsweep.pl . The first, loggedcron.pl runs a command and saves the output in ~/cron_logs . The second, gitsweep.pl, pushes the contents of ~/cron_logs into a remote git repo.
So, for example, if you want a record of how much free space you have every night at 1:02, enter the following in your crontab (with appropriate changes of course):
02 01 * * * /home/dave/bin/loggedcron.pl df -k * * * * * /home/dave/bin/gitsweep.pl