Today I’ve put the finishing touches on python-crontab 1.4. This release updates the tests and fixes a couple of bugs as well as two really interesting features.
The first is the ability to pull a log from a crontab or cronjob. When creating a crontab in the usual way you can specify a optional log file, if not specified the value ‘/var/log/syslog’ is substituted. The log attribute then provides you a filtered log view which limits the lines returned by the iterator to those attributed to the user your crontab controls. This is of course by default the ‘root’ user, but can be other users too.
Conversely each job in the crontab can return a log iterator which limits the retuned entries to those for this job only. This allows the programmer to tell when cron jobs were last run.
The second large feature is the scheduler. Using the croniter python module, this feature returns date/times when cron jobs would run from any given datetime offset. This allows the programmer to compile a list of datetimes when the job would run in the future and in the past. Use the schedule attribute from the cron job object.
You can download the new release here: python-crontab-1.4 on PyPi