I needed to set up something to start at a time certain last night in what used to be crunchbang (considering I replaced over half the stuff in the default base, it’s not so much crunchbang anymore). That means using the at command; cron is a great tool for things that need to repeat on a schedule, but at is the tool to use for “one shot” events.
I entered “at 22:00” and wasn’t too surprised it threw out an error when I hit return. I looked in /etc and saw there was only the at.deny file but no at.allow. So I quickly added my username to at.allow. Then running at again showed that a certain file didn’t exist. Again, no big surprise — I openly admit a bias against Ubuntu because it uses shitty graphical utilities rather than setting up standard tools. So my next step was to setting up (touch) the file .SEQ in /var/spool/cron/atjobs.
% sudo su root@pluto:/etc# cd /var/spool/cron/atjobs/ root@pluto:/var/spool/cron/atjobs/# touch .SEQ root@pluto:/var/spool/cron/atjobs# ls -al total 8 drwxrwx--T 2 daemon daemon 4096 2009-07-26 21:27 . drwxr-xr-x 5 root root 4096 2009-06-30 05:53 .. -rw-r--r-- 1 root root 0 2009-07-26 21:27 .SEQ
Uh oh, that won’t friggin’ work — it’ll result in denial of permission (unless you run as root, which isn’t necessary):
% at 21:30 warning: commands will be executed using /bin/sh Cannot open lockfile /var/spool/cron/atjobs/.SEQ: Permission denied
The file needs daemon-daemon ownership. This is very easy to fix. See how easy it is, boys and girls?
root@pluto:/var/spool/cron/atjobs# chown daemon.daemon .SEQ root@pluto:/var/spool/cron/atjobs# ls -al total 8 drwxrwx--T 2 daemon daemon 4096 2009-07-26 21:27 . drwxr-xr-x 5 root root 4096 2009-06-30 05:53 .. -rw-r--r-- 1 daemon daemon 0 2009-07-26 21:27 .SEQ root@pluto:/var/spool/cron/atjobs# exit
Once I had that set up, I could test it to play a file (I wrote this Sunday night).
% at 21:30 warning: commands will be executed using /bin/sh at> ogg123 ~/audio/fuckinaye.ogg<EOT> job 2 at Sun Jul 26 21:30:00 2009
The EOT at the end of fuckinaye.ogg is just ctrl-d (remember that from when mail was a true commandline program?). At 9:30pm, I heard the test ogg file.
Now with it properly set up, I can use it to launch individual tasks when I need them and I don’t have to run X to do it from some stupid box with dials and buttons.