November 2007 Archives

On Unix the universal job scheduler is "cron" (the other universal but less commonly known daemon is the at daemon). On Unix systems everywhere, lots and lots of batch jobs are kicked off all day from the cron daemon. The typical configuration looks something like this:

18 2 * * * ~/bin/some_batch_job

This means at 18 minutes past the hour at 2am on every day of the month of every month of every weekday, run the following command (You can read about the configuration format by typing man 5 crontab on the command line of a nearby unix-y system).

Why 18 minutes past the hour? For an hourly job you often want to pick a "semi random" time of the hour to run the job. If you run the same batch job on several servers all accessing a shared resource for example.

Sometimes though then the configuration has to be exactly the same everywhere, but you still want to spread out the runs. Or it's a job that runs every minute or two on many systems. Or you have a system that just runs a lot of cronjobs and you can't have them all start at exactly the same second. You have to introduce second granularity to spread them out. But how? The cron format works with minutes at the lowest granularity.

You use the magic $RANDOM variable in the shell!

You can get a random number by just accessing $RANDOM, try it:

echo $RANDOM

If you want a number between 1 and 10 you do a modulo operation on the random variable. In shell syntax that'd be

echo $(expr $RANDOM % 10)

The $( ... ) syntax works like backticks, runs the command and returns the result. The expr command runs the arguments as a shell expression.

Now if you want to run a command (on average) every two minutes, but spread out the executions over 90 seconds, you can do

*/2 * * * * sleep $(expr $RANDOM \% 90); ~/bin/batch_job

This will run the cronjob every 2 minutes (120 seconds), but wait between 0 and 89 seconds before running the actual script. Magic!

Whenever you setup something to access a remote resource (RSS feed, NNTP server, ...) it's always polite to do this, otherwise the server operator will get an onslaught of requests exactly on the minute -- or even worse at the top of the hour.

volume_change.pngBy default in OS X when you hit the volume keys on the keyboard the OS X gives a little “click”. In 10.5 there’s an option to disable it (Sound Preferences, “Play feedback when volume is changed”. Is that option in 10.4 too?). However, if you usually want it on you can still selectively make the adjustment silent.

Just hold down the shift key while pressing the volume button. I think this is a new feature in 10.5, but I’m not sure - I stumbled over it accidentally (accidentally holding down random keys - amazingly I ever get the computer to do what I want!). It works on the “real” keyboard on my PowerMac, but not on the internal keyboard on the MacBook Pro - I haven’t tried with an external keyboard on the laptop yet.

Does it work for you?

This must be the craziest spin I've seen in a while:

"We're asking a lot of soldiers these days," said Roy Wallace, director of plans and resources for Army personnel. "They're humans. They have all sorts of issues back home and other places like that. So, I'm sure it has to do with the stress of being a soldier."

So they're deserting to go home because of their "issues" there? Uh-huh, sure ...

.Mac iDisk going crazy, again.

| 3 Comments

I use Apples .Mac service and it must be one of the worst "Apple experiences" ever. I can't believe I keep paying $100/year for that crap[1].

Let's not even talk about the countless times the sync thing has gone amok and made all such of crazyness of the data it's supposed to sync (it seems like that part has gotten better in Leopard, crossed fingers).

What hasn't gotten better is their brain-dead iDisk product. It still seems to be missing basic encryption. Since upgrading to Leopard it's a frequent occurrence that it comes up with duplicate problems "which of these both ancient versions of the file is newer". Apparently that's an ongoing problem, now WEEKS OLD. Hello! How hard can it be? Also - it CRASHES if the request goes through a proxy server. How can they not have tested that? Apparently this is also a widespread problem.

Anyway, that's not even what I'm going to talk about. I have 2GB allocated to the iDisk. In Tiger and earlier it'd actually take that much room on the disk, even if you only used it for a few hundred MB. I have about 500MB on my iDisk. In Leopard they finally got it changed so it's using a new "sparsebundle" disk image type instead of a "sparseimage". The change here is that it stores the disk image in a bunch of little files, presumably to make it friendlier to the Time Machine for backups. So far so good. Until last night when I went to put the computer to sleep and saw roughly all my programs had crashed and those that had not had dialogs up about the disk being full. Why? Because the idiotic iDisk sync had decided to just EAT UP ALL DISK SPACE.

$ du -sh ~/Library/FileSync/
16G /Users/ask/Library/FileSync/

Nice going! It must be hard to store several hundred megabytes, so let's take ALL AVAILABLE DISKSPACE to do it. If I had been using my new 1TB disk as the system disk I'm sure it'd have kept going until it was full, too. After clearing some other space up and restarting it can't even figure out to get rid of the waste space here.

And the iDisk lost the file changes done in the last few days. Yay! I can't believe that I (until recently) was relying on the iDisk for several important files.

I am really really happy that I'm using Jungle Disk and Amazon S3 for storing my new paperless paper archive (more on that another day).

I'm going to write to Apple/DotMac Support and ask if they have an explanation. What do you think my odds are?

(1. To answer the question from the first paragraph: I know why I keep giving them my money for this: it's because syncing my address book and keychain is really really really nice, when it works). $100 nice though? Geez!)

About this Archive

This page is an archive of entries from November 2007 listed from newest to oldest.

October 2007 is the previous archive.

January 2008 is the next archive.

Find recent content on the main index or look in the archives to find all content.

Pages

OpenID accepted here Learn more about OpenID
Powered by Movable Type 4.25