Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: vdr Restarting Tool (cron Job + Perl)



Hi

i just daw that the mailinglist has stripped my attachment so here is
the perl script i wrote:

ciao markus 

#!/usr/bin/perl -w

use File::Basename;

#
# Here you have to change the path to get it working
# as we will be using the runvdr script make shure it's
# also located in that dir!!
$vdrPRG = "/PathOfYourVdrProgrammDir/vdr";


$vdrDIR = &dirname($vdrPRG);

#
# the file where you want some log info writen to
$vdrCronLOG = "/var/log/vdrCronJob.log";


#
# First we check if the vdr is still running. I'm doing that
# with the ps tool as i not yet found out how that would be
# done in perl ;)
open (PS,"ps -ef | grep ".$vdrPRG." |");
@ps = <PS>;
close(PS);

# so now we have some lines like
# vdrusr 20037 20035  0 01:17 pts/2    00:00:02
/PathOfYourVdrProgrammDir/vdr -w
# in that array @ps if the vdr is still running and if it's not
running there
# should be no lines and so we have to check if the array is empty
if ( @ps == 0)
  {
    # lets restart the vder using the run script
    system($vdrDIR."/runvdr &");
    # now let's write somethin into the log file
    open(LOG,">>".$vdrCronLOG);
    print LOG "Restarting vdr with checkvdr.pl script\n";
    close(LOG);
    # put the date into the log file using the date programm from
linux
    system("date >> ".$vdrCronLOG);
  }



On Mon, 1 Jul 2002 02:25:39 +0200
Markus Kalb <Markus.Kalb@gmx.net> wrote:

> Hi 
> 
> as my vdr was chrashing a lot in the last days and the watchdog
> didn't catch all of them i wrote a little perl script that is
> startet every 5 minutes by the cron deamon and if ther is no vdr
> running it restarts it. 
> 
> The script itself is included as a attachment. i have tried to
> comment it as much as possible so that all of you should be able too
> understand what is going on if you want to take a look. 
> 
> Important to now are the following things. 
> 
> a) the script asumes that you started ypur vdr with a full path just
> as the runvdr script does that. so if you run the followin on the
> command line 
> 
>   "ps -ef |grep vdr"
> 
> you should  get something like 
> 
> vdrusr    21656 21654  0 02:11 pts/2    00:00:00
> /home/vdruser/vdrXyZ/vdr 
> 
>  
> b) for restarting my script uses the runvdr script so make shure
> it's in the dir you configure in the attached checkvdr.pl file. 
> 
> 
> c) this software is a quick hack and is so far only tested on my
> system 
> 
> d) if you have problems you can mail me, but if i have time to help
> you is a totlay other thing so maybe you might have to wait a little
> bit ;)
> 
> e) you need to put the line below in the crontab of root. That is
> done with "crontab -e" and you will have to change the "/root/bin/"
> part to whereever you put the script. With this setting the check is
> done every 5 mins. if you want it done every 10 minutes just replace
> 5 with 10. for more info about that you can also execute "man 5
> crontab" 
> 
> */5 * * * * /root/bin/checkvdr.pl
> 
> 
> f) the software is realeased under GPL 
> 
> d) may your life prosper as long as the force is with you 
> 
> 
> ciao marks 
> 
> 
> -- 
>  /"\         Markus Kalb <markus.kalb@gmx.de>
>  \ /	                GnuPG Key ID B93BDF1E
>   X ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
>  / \
> 
> 
> -- No attachments (even text) are allowed --
> -- Type: application/octet-stream
> -- File: checkvdr.pl
> 
> 
> 


-- 
 /"\         Markus Kalb <markus.kalb@gmx.de>
 \ /	                GnuPG Key ID B93BDF1E
  X ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
 / \




Home | Main Index | Thread Index