A short addendum to my previous post…

I forgot to explain the reason I decided to write my own scheduler. I could’ve used cron or atd, but those daemons aren’t the most user-friendly to quickly set schedules for. cron may be standard on Linux and BSD systems but the format is arcane, error-prone and non-intuitive. It’s not horrible but I’m a bit surprised something more sensible hasn’t replaced it. atd is more human, but I wanted a configuration file where I didn’t have to know the date when a show began to record it – only the weekday. Then the script would figure out what date that weekday fell on and act accordingly.

Actually it turns out you can sort of do this with atd, although it’s not documented, at least not on the man page, and the time and weekday are reversed. To run a command at 7pm on the upcoming Wednesday:

$at 19:00 Wed << END
? echo Hello world.
warning: commands will be executed using /bin/sh
job 7 at Wed Sep  4 19:00:00 2013

$ atq
7       Wed Sep  4 19:00:00 2013 a ozzmosis

The other advantage is the configuration of my scheduler accepts an end time, which allows it to calculate the recording duration and display it to the user.

The other issue with the cron and atd daemons is that you don't get to see the output of the command in realtime. Instead you get an email after the command has completed, which isn't always ideal for doing scheduled recordings. There are probably a few ways around that, but I'm not keen on them.

Due to the script requiring the Python interpreter, and it never actually terminating (unless you hit Ctrl+C), there is a small amount of memory overhead from having Python loaded in memory all the time. On modern PCs this is trivial, though. There is also no measurable CPU overhead from having the script continuously running in the background - the call to time.sleep() takes care of that.

Lastly, the source code to the script is released to the public domain. You are free to do what you want with it and credit me if you feel like it (or not). I'm sure it has other uses.


Leave a Reply

Your email address will not be published. Required fields are marked *

Anti-Spam Quiz: