I have the same problems on my servers at work (SCO 5.0.5) and quite a while ago I created a small shell script to deal with the problem. You could write this is perl as well but I see no point to it. This works in straight sh so you should be fine with it anywhere. The below code has had the checking part of it removed for brevity.