#!/bin/bash
# autorun.sh by Ondrej Jombik, 22.9.2000, 14.11.2000, 11.12.2000
# Toto je autorun-script na kontrolu nahodeneho scriptu. Funguje tak, ze
# ku kazdemu scriptu, ktory chceme kontrolovat musime vytvorit jeden
# takyto autorun-script. Tento autorun-script zapiseme do crontab. Potom
# bude v pravidelnych casovych intevaloch kontrolovat nas script, ci bezi.
# Pokial script nebezi, tak ho autorun-script znovu nahodi.
# Adresar spustaneho scriptu.
scriptdir="$HOME/autorun/"
# Nazov spustaneho scriptu.
script="maxzaw.sh"
# Parametre scriptu
scriptparams=""
#############################################################################
cd $scriptdir
# Existuje PID subor?
if [ -r $script.pid ]; then
scriptpid=`cat $script.pid`
if `kill -CHLD $scriptpid >/dev/null 2>&1`; then
exit 0
fi
echo "PID file '$script.pid' found."
echo "Invalid PID ($scriptpid), script '$script' probably not running."
echo "Removing '$script.pid'."
rm -f $script.pid
else
echo "PID file '$script.pid' not found, script '$script' not running."
fi
# PID subor neexistuje. Vytvorime ho.
echo "Creating '$script.pid'."
echo $$ > $script.pid
# Nahodime script.
echo "Running '$script'."
./$script $scriptparams
# Script skoncil. Zmazeme PID.
echo "Script '$script' finished (or killed), removing PID file '$script.pid'."
rm -f $script.pid
# Koncime.
echo "Terminating..."
exit 0
Platon Group <platon@platon.sk> http://platon.sk/
|