final version here, {because I made some error, of editing }
####################################################
##################################################################################
#!/bin/sh
###############################################################################
if ! ps x |grep -v grep |grep -c /usr/bin/oscam_r5893 >/dev/null
# example { if ! ps x |grep -v grep |grep -c /emu/oscam/oscam.x86 >/dev/null }
#/usr/bin/oscam_versionexxxx
#also take attention to the path to Oscam binary !!!!!!!
then
# oscam start or restart
/usr/bin/killall -9 oscam_r5893
/usr/bin/oscam_r5893 &
#/usr/bin/oscam_versiunexxxx
#also take attention to the path to Oscam binary !!!!!!!
echo `date "+%d/%m/%y %R Oscam NOT working , restarting...."` >> /var/log/oscam.check
# This part above will check if there is NO oscam process running.
# And if this condition it truth, it will start it and write to log.
# Log entry will contain time stamp and reason of execution (process not working)
# If first condition in not truth (oscam was running), go further to next condition.
elif
tail -8 /var/log/oscam.log |grep -v grep |grep -c ins40 >/dev/null
then
#oscam restart
/usr/bin/killall -9 oscam_r5893
/usr/bin/oscam_r5893 &
#/usr/bin/oscam_versiunexxxx
echo `date "+%d/%m/%y %R ins40 error detected"` >> /var/log/oscam.check
elif
tail -8 /var/log/oscam.log |grep -v grep |grep -c deadlock >/dev/null
then
#oscam restart
/usr/bin/killall -9 oscam_r5893
/usr/bin/oscam_r5893 &
#/usr/bin/oscam_versiunexxxx
echo `date "+%d/%m/%y %R deadlock error detected"` >> /var/log/oscam.check
# Those 2 conditions will look for 2 common errors in Oscam: "ins40" and "deadlock"
# If last 8 lines of your oscam.log contain any of those errors, it will restart oscam.
# Log entries will include the exact reason of restart.
# ins40 error is random error that will keep oscam running but no CWs returned.
# deadlock is older error that appear if you use CCcam protocol in oscam.server
else
echo " Oscam still ok 2 "
#echo " Oscam still ok 2!" >> /var/log/oscam.check
echo `date "+%d/%m/%y %R Oscam still ok 2!"` >> /var/log/oscam.check
# If oscam passes all conditions and all is OK, it will simply echo "Oscam still OK 2 !"
fi
##################################################################################
#!/bin/sh
###############################################################################
if ps x |grep -v grep |grep -c usr/bin/CCcam_2.1.3 >/dev/null
#if ps x |grep -v grep |grep -c CCcam_2.1.3 >/dev/null
then
echo "CCcam OK 3"
#echo "CCcam OK 3" >> /var/log/CCcam.check
echo `date "+%d/%m/%y %R CCcam OK 3"` >> /var/log/CCcam.check
else
echo "CCcam restarting"
#echo "CCcam restarting" >> /var/log/CCcam.check
echo `date "+%d/%m/%y %R CCcam restarting... "` >> /var/log/CCcam.check
/usr/bin/killall -9 CCcam_2.1.3
/usr/bin/CCcam_2.1.3 &
fi
######################
####End of script ####
######################
####################################################
Tested, and Works well
22/06/13 21:34 Oscam still ok 2!
22/06/13 21:35 Oscam still ok 2!
22/06/13 21:36 Oscam NOT working OK
22/06/13 21:37 Oscam still ok 2!
22/06/13 21:38 Oscam still ok 2!
................
22/06/13 22:23 Oscam still ok 2!
22/06/13 22:24 Oscam still ok 2!
22/06/13 22:25 Oscam still ok 2!
22/06/13 22:26 Oscam still ok 2!
22/06/13 22:27 Oscam still ok 2!
22/06/13 22:28 Oscam still ok 2!
22/06/13 22:29 Oscam still ok 2!
22/06/13 22:30 Oscam still ok 2!
22/06/13 22:31 ins40 error detected
22/06/13 22:32 Oscam still ok 2!
22/06/13 22:33 Oscam still ok 2!
...............