Crontab

Cron is useful for scheduling jobs (ls /etc/cron.*) and fairly easy to place under version control. The crontab command is also very useful, but not so easily placed under version control as all crontab entries for a user go in a single file and that file is kept in /var/spool/cron/crontabs. As others have said before, version control of all cron entries is a good thing.

There are some programs that I like so much that I leave them running much of the time, even though they waste more CPU and RAM than I would like. One such program is xmobar. Somewhere within my MCM desktop configuration I have a line like the following, for I have no use for xmobar when I am asleep:

MCM CrontabUse

import Crontab as Crontab

define oak()
	Crontab.crontab home> @home hour> 22,23,00 minute> 15
		cmd: pkill xmobar || true

Thanks to this next snippet of MCM, that entry is carefully combined with entries from other places to maintain my crontabs for me.

MCM Crontab

import MCM.Hooks as Hooks

define crontab(cmd home
		dayofmonth = *
		dayofweek = *
		hour = *
		minute = *
		month = *
	)
	let file = @home/tmp/.mcmcrontab
	File mode> 644 path> @file
		content: DISPLAY=:0.0
			+ PATH=/bin:/usr/bin:/usr/local/bin
			+$fragments(crontab,,@NEWLINE,)
	Fragment group> crontab
		content: @minute @hour @dayofmonth @month @dayofweek @cmd
	Hooks.runUnless
		command: crontab @file
		cond: crontab -l | diff - @file