#!/bin/sh
if [ -z "$3" ]
then
  echo use: $0 lockname logfile program_id_for_messages
  exit
fi
nd=`date +%s`
if [ -s "$1" ]
then
  od=`cat $1`
  echo --------------------------------------- >> $2
  echo $3: `date` Already running from `date -r $od` >> $2
  if [ `expr $nd - 18000` -gt $od ]
  then
    echo FUCK IT | mail -s "$3: $1 is too old! Check it!" andrej
    echo TOO OLD LOCK >> $2
  fi
  exit
fi
echo $nd > $1
exit 1
