---

Linux Gazette: Running UNIX At Home

I started using UNIX years ago at school, so when Linux
came along I eagerly installed it on my home computer so that I
could have the same wonderful operating system in both places.
Linux has worked amazingly well for me, but after a while I noticed
that it wasn’t completely adapted for home use.
“locate”‘s
database wasn’t getting updated, the log files kept growing and
growing, and the startups and shutdowns were taking a fair chunk
out of my day. This was because UNIX computers traditionally stay
on all the time, while home computers tend to be frequently turned
off.”

“None of my cron jobs, like updating locate’s database and
trimming the log files, were being done since the computer was
hardly ever on in the wee hours of the morning, the time chosen by
the distributions (Slackware, then Red Hat 3.0.3, then 5.1) for
housecleaning. Very early in the morning is perfect for computers
that stay on all the time, since that’s when there are the fewest
users to be upset by the somewhat disruptive janitorial jobs, but I
was unwilling to leave my computer on all them time just to make
cron happy. I ruled out changing the job running time to something
during the day, since I tend to run my home computer at
unpredictable times for a few hours. The only way I could be sure
the jobs would be done would be to run them hourly instead of daily
or weekly. That would soon get annoying. My solution, the following
script, was to combine an hourly cron with batch, and to check
whether the job had already been done satisfactorily recently. The
hourly cron is frequent enough that it will probably get a chance
while I have the computer on, but batch minimizes my annoyance by
only running the jobs when the computer isn’t too busy, like when
I’ve gone for a snack. The timestamp check cancels the job if it’s
already been done in the last week/month/etc.”

Complete
Story

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends, & analysis