Debian-based distributions have a really useful series of directories to run cron scripts from. Any executable you place in /etc/cron.hourly, /etc/cron.daily, /etc/cron.weekly or /etc/cron.monthly will get run with that frequency. I like these for two reasons: 1) it’s file-based, which I find a lot easier to manage and keep track of than each user’s crontabs and 2) this eliminates one possible source of bugs in my work – namely, the scheduling of my cron tasks.

However, there is a downside to /etc/cron.daily and friends. All scripts in there run as root. It’s generally bad practice to run anything as root that doesn’t have to run as root… and this is especially true if your script has scary lines like “rm -rf $SOME_VAR” in it. You’re asking for trouble.

Unfortunately, AFAIK there is no way to drop privilege within a script. However, this can be done by spanning a whole new child process. So, let’s add a short preamble to all the scripts we place in /etc/cron.daily and friends:

#!/bin/sh

USER='some-low-privilege-user'
if [ `whoami` != "$USER" ]; then
  sudo -u $USER "$0"
  exit
fi

... rest of the script ...

Now we have some extra assurance our cron job isn’t going to go haywire and screw the whole machine!

I’ve played out this script like too many dozen times:

friend: “I need a new computer!”
me: “why…?”
friend: “cause it’s slow.”
me: “have you tried reinstalling windows?”

Actually, even better than reinstalling windows is to switch to an operating system that won’t bog your computer down with unnecessary fancy fades, transparencies, drop shadows and the like.  But this requires a little more than a ‘little’ effort.  However, as a testament to how much more power can be milked out of a machine than we like to give credit for, check it out:

OmniBook 900

Running my RSS reader, (and firefox, thunderbird and like 8 copies of vi in the background) that is an OmniBook 900 which I bought for $50 2 years ago. It’s an 8-year-old machine. Count them… 1… 2… 8!

$ cat /proc/cpuinfo | grep '\(vendor_id\|model name\|cpu MHz\)'
vendor_id      : GenuineIntel
model name     : Pentium III (Coppermine)
cpu MHz        : 498.469
$ cat /proc/meminfo | grep 'MemTotal'
MemTotal:       321332 kB

Albeit a little slowly, it’s running all the stuff I normally use a computer for on a day-to-day basis. (I’m blogging on it too! omg ponnies!) And it’s got less power than my phone. Not to say we should all be running 8-year-old laptops, but it is to say that computing is not headed toward more and more power, but rather toward more and more mobility, integration, and ubiquity. Funny how some of the big guys don’t get it.

And it is also to say, next time you’re thinking about replacing your machine cause it’s running a little slow… what you’re really trading off is the time and effort it would take for you to reformat & reinstall your existing machine versus the $2k it’ll cost you for a brand new one. But even that brand new one – depending on who you buy from, they may throw in pre-configured malware for you at no extra asshole-fee… so best practices would be to immediately reformat & reinstall anyway.

Moral of the story? Just don’t pay for extra computing power so that you can run your malware and your drop shadows and your anti-virus (arguably an even better resource hog than the malware itself) all on top of each other. Reinstall your windows one or two times a year – that’ll do more to keep you moving fast on your machine than buying a new one will. And while you’re clicking ‘yes I’m sure’ for the googlith time, think about switching over to the side of the penguin. It burns a little at first… but grows with age.

Fun times figuring this out…. AFAIK, this will work for the whole HP Photosmart 2570 series. I’ve got a Photosmart 2575.

First, set up your Photosmart 2575 to print over the network. This is (relatively) simple… install the debian package hplip, then use the gnome Applications->System Tools->Printers GUI to go from there. Or… use the cmd line to get there.

A default debian lenny installation with the joy that is OpenOffice will come with xsane installed. Applications->Graphics->Xsane. Try it… it will fail to find your HP Photosmart.

You have issue #2. To fix this, you need your printer’s IP address, which there are several ways to get. One way: navigate your favorite browser to http://localhost:631 to access your CUPS admin page (creepy, huh? your laptop is running a http server? surprise!). Find your Photosmart 2570 series printer under ‘Manage Printers’, its IP address will be listed there.

Now, using a terminal, run xsane with the following argument:

xsane hpaio:/net/Photosmart_2570_series?ip=xxx.xxx.xxx.xxx

Where xxx.xxx.xxx.xxx is the IP address of your Photosmart 2570 series printer on your local network. Xsane should be able to find your HP Photosmart now. Enjoy….!