Sometimes, you don’t want a script to run when it is already running. Maybe it is scheduled as a cronjob but the previous run of that cronjob hasn’t finished yet.
I usually do some “pre-flight checks” in almost every script I write. And most times, this is one of them.
Here’s how:
#!/bin/bash
# check if we are the only local instance
if [[ "`pidof -x $(basename $0) -o %PPID`" ]]; then
echo "This script is already running with PID `pidof -x $(basename $0) -o %PPID`"
exit
fi
# start your script here
It’s that easy. It can even be made a one-liner:
if [[ "`pidof -x $(basename $0) -o %PPID`" ]]; then exit; fi
pidof (program name here)returns the process ID(s) of every running instance of the specified program. The -x switch tells pidof to include scripts, these are usually excluded. $(basename $0) is being replaced by the name of your script when you execute it, and the -o switch omits a given PID or, in this case, the PID of this very script, that’s what the special %PPID parameter is for. So when this script is run and the check fires, it won’t count itself.
One more thing: You must call your scripts directly, like ./something.sh, NOT like sh something.sh, otherwise this trick will not work. This means your script needs to have the executable flag set (chmod +x it).
No Comments »
Run
sudo touch /forcefsck
Next time you boot, the file system will be checked.
No Comments »
So I upgraded to Thunderbird 3 some time ago. It has nice new features, like the grouped folders. Anyway, there are a few things that annoyed me too; one of them being the fact that whenever someone sends a mail to me and some other people, only the first recipient was displayed, with a “more…” button next to it. The settings unfortunately do not allow to turn this behaviour off, but there’s a hack to do this (maybe in the future, they’ll include a setting…) Read the rest of this entry »
No Comments »
Posted by Jay2k1 in Hardware, How-To, Linux, tags: grub2, hauppauge, htpc, mythbuntu, mythfrontend, mythtv, mythwelcome, nvram-wakeup
So I decided it’s time to build a HTPC so I can record TV and also use time shifting when watching live TV.
I’ve tried several products, be it software packages or whole linux distributions, including Windows Media Center, Apple Front Row, vdr, c’t-vdr, yavdr, freevo and mythTV. That last one I liked most by what it offered, so I gave it a try. I stumbled upon many things on my way though. I’ll write down the ones I remember here, perhaps it’ll help someone some day. Read the rest of this entry »
No Comments »
The problem
Did you ever want to install a font on your Mac that’s on a SMB share, for example on a Windows/Unix server? Did you experience the font was broken somehow, being displayed in the finder as “unix executable file” with 0kb size?
We had this issue here often, finally I figured out why this happens.
Read the rest of this entry »
2 Comments »
Trying to integrate Zimbra calendars in Lightning, I ran into a couple of problems. So far I’ve found four different ways to do it in the internet:
- ICS: http://zimbrahost.example.com/home/USERNAME/CALENDARNAME
- ICS: webcal://zimbrahost.example.com/home/USERNAME/CALENDARNAME
- ICS: webcal://<USERNAME>:<PASSWORD>@zimbrahost.example.com/home/USERNAME/CALENDARNAME
- CalDAV: http://zimbrahost.example.com/dav/USERNAME/CALENDARNAME
Now the ICS solutions don’t work properly for me, the calendar entries are loaded but Lightning is unable to write to the calendar (when editing entries, deleting entries, creating new entries).
CalDAV is working, but only when using one calendar, as it seems. I created a second calendar in the Zimbra Webinterface though, and when I try to add the second calendar the CalDAV way, I get a yellow warning sign next to the calendar name saying “The calendar <name> is not available at the moment”. So CalDAV seems to be limited to one Calendar per user or server.
I didn’t find a solution yet.
No Comments »
These are my post-installation steps in Fedora 10.
After I read that Fedora 10 is out on heise.de, I thought, let’s give it a try. Here I’ll describe what I did to set up the fresh install for my needs.
Note: I installed Fedora 10 from the full i386 DVD (not live CD!) on my HP 2510p notebook, just in case you’re interested about hardware.
Read the rest of this entry »
No Comments »