Prefix command output in a shell with timestamp

no comments

So I was writing this script that logged certain things to a file using a regular redirect. My script was running various commands that outputted a random amount of lines, all in random formats. I wanted to have a timestamp prefixing all of that, similar to what you get in logs written by syslog. I searched around a bit, and ended with this:

Of course if you want a different timestamp, you just change the arguments you pass to strftime. Quite handy!

Tail with word highlighting

no comments

If you’ve ever ran tail -f on a busy file and tried to find certain words or patterns as they fly by, then this little “trick” might be of some help:

URL shortening service

no comments

Having this short domainname (yay!) I early made my own URL shortening service of sorts. It was based on a perl-script I found online, and had a mapping between the keys and the long URL’s in a textfile. Also, I used a subdomain of for this purpose, namely This wasn’t good enough of course, way too long, so this weekend I wrote my own URL shortening service, using PHP. It stores the keys and URL’s in a database, and supports logging of each lookup done to a short URL. And most importantly, it has an easy interface to add new URL’s, which is something that couldn’t be said for my old text-file solution. Feel free to use it for any of your URL shortening needs.

So without further ado, here it is:

Shell-script template for cronjobs

no comments

Have you ever had your server drown in processes because a cronjob you wanted to run every minute suddenly never finished, and you ended up having multiple instances of your nice script going at the same time? I have! A quick and easy solution to this problem, was this wrapper-script that I created a while back. Basically, it’s just some pid-file processing before your own code starts, to make sure only to run a single instance of the script at a time. With this you’ll avoid having your scripts pile up again.

The script:
The config: cron-shell-script-template.conf-sample

If you find this script useful, or have some improvements, feel free to drop me a comment below. Thanks!


The script had a little bug, which caused two instances of the script to be started under some circumstances. The script behind the link above has been updated to correct this.

Update, July 23.:

I’ve removed the PIDDIR-setting from the actual script, and moved it to a separate configuration-file. It’s all generic, the conf-file is expected to be named the same as the script with the last “.ending” replace with “.conf”. The point of this is to be able to e.g. keep the script itself in a repository (like subversion) and keep the config separate so you can update the script from the repository without having local changes to worry about.

Amy LaVere at John Dee

no comments

An email newsletter from the local concert-scene in Oslo tempted me to visit John Dee to see and hear Amy LaVere from Memphis, Tennessee play on wednesday may 6th. I had never heard about her before, but the mini-review in their newsletter made me stop by her MySpace-page to hear some of her songs. It isn’t (well, wasn’t) not my typical music, but it sounded really good, good enough to warrant a live experience. She plays the contrabass with style, and has a really nice, graceful and slightly rustic voice.

More: Read the rest of this entry…