View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 50 posts ] 
Go to page 1, 2, 3, 4  Next

Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Thu Jan 18, 2007 5:26 pm 
Offline
Joined: Fri Nov 18, 2005 9:22 am
Posts: 777
Location: spencerport, ny (USA)
Link: http://www.thornsoft.com/Misc/babysit_backend.sh
Since upgrading to R5E50, which I love, I've had problems with the backend not being up when it's supposed to be. I understand that this issue is being worked on. In the meantime, I wrote a script that can be run from crontab to re-start the backend if it's down.
If it sees the backend running with a non-defunct process ID, it just exits.
If it doesn't see the backend, and none of the following conditions apply, it'll re-start it.
Exceptions:
mythfrontend is down (you're probably doing some other maintenance)
mythbackup is running
mythrestore is running

You can easily extend it to add exceptions too.


Installation:
From a directory such as /tmp, as root:
Code:
wget http://www.thornsoft.com/Misc/babysit_backend.sh
cp babysit_backend.sh /usr/local/bin
chmod +x /usr/local/bin/babysit_backend.sh


run: babysit_backend.sh
It should exit with no messages, if the backend is running. Otherwise it'll restart it.
Suggested usage - add this line to crontab:
Code:
* * * * * /usr/local/bin/babysit_backend.sh >>/var/log/mythtv/babysit_backend.log 2>&1


Note: See the note by "bigbro", if your contab lists a user. Mine doesn't, and I don't know how common this is.

This runs the job every minute. It'll handle re-starts after reboot (just wait a minute, and it'll come up) and also those pesky random crashes that always seem to happen right before the wife's show is supposed to record.

Please leave feedback, suggestions, fixes here.

Also see my "mythcommflag babysitting script", which ensures low cpu usage by commflag:
http://mysettopbox.tv/phpBB2/viewtopic.php?t=13614


Last edited by thornsoft on Fri Jan 19, 2007 10:25 am, edited 2 times in total.


Top
 Profile  
 
PostPosted: Thu Jan 18, 2007 7:09 pm 
Offline
Joined: Wed Nov 16, 2005 8:55 pm
Posts: 1381
Location: Farmington, MI USA
Hi thornsoft,
You'll want to remove the Home: portion from the wget line.

thornsoft wrote:
...and also those pesky random crashes that always seem to happen right before the wife's show is supposed to record.

Ain't that always the way? :D


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 18, 2007 7:36 pm 
Offline
Joined: Sat Dec 24, 2005 11:33 am
Posts: 400
Location: Kitsap Peninsula, Wa., United States
I tested this all files seemed in right places and it works in R5C7.
Should really help the WAF when I don't miss a particular show like has happened the last two Wednesday's in a row.
Still trying to determine why the MBE suddenly disappeared.

Anyway, I noticed when it runs and exits with no error I get no indication in the babysit-backend.log I assume that is normal.

Can you post a sample of what I might see if it had to restart the backend?

Thanks!

_________________
KnoppMyth R5.5
MBE: AMD64 3400+, K8N Neo4 Plat., 1Gig, Asus Extreme N6200, 320G pata, 2x320Gsata, 750Gsata, PVR-150 Retail w/Blaster
SBE: AMD XP2000, GA 7ZMMH, 1 Gig, XFX 256M 6200, 20 Gig, PVR-150 Retail w/Blaster
SBE: AMD Dur1800, 512M, PVR500


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 18, 2007 8:54 pm 
Offline
Joined: Fri Nov 18, 2005 9:22 am
Posts: 777
Location: spencerport, ny (USA)
bigbro wrote:
Anyway, I noticed when it runs and exits with no error I get no indication in the babysit-backend.log I assume that is normal.

Yeah, I had logging in there, and it was just in the way so I yanked it.

Quote:
Can you post a sample of what I might see if it had to restart the backend?


Something like this:
Code:
Myth Backend Babysitter Run At Thu Jan 18 14:10:01 EST 2007
babysit_mythbackend Needs to re-start Myth Backend at Thu Jan 18 14:10:01 EST 2007.
Restarting MythTV server: mythbackendNo /usr/bin/mythbackend found running; none killed.
.
.
Sleeping....
Myth Backend restarted as process 3180.


You can test it easily. Just press Alt+2 to kill the backend, and wait a minute. You'll get output.

slowtolearn - thanks for the heads up on the typo. I fixed it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 18, 2007 11:42 pm 
Offline
Joined: Sat Dec 24, 2005 11:33 am
Posts: 400
Location: Kitsap Peninsula, Wa., United States
Thanks for the input and what it should look like.

As soon as I got a break in the "Schedule" I stopped my backend.
It didn't work. I went in and Checked my cron.log
Here is what I saw>
Quote:
Jan 18 17:30:01 mythtv /usr/sbin/cron[4546]: (*system*) RELOAD (/etc/crontab)
Jan 18 17:30:01 mythtv cron[4546]: Error: bad username; while reading /etc/crontab


So I made a change that I would suggest to your Crontab line.

Changed this:
Code:
* * * * * /usr/local/bin/babysit_backend.sh >>/var/log/mythtv/babysit_backend.log 2>&1


To this:
Code:
* * * * *  root /usr/local/bin/babysit_backend.sh >>/var/log/mythtv/babysit_backend.log 2>&1


Now I see it running in my Cron.log and it does not present that error at first run.
Quote:
Jan 18 21:34:01 mythtv /usr/sbin/cron[4546]: (*system*) RELOAD (/etc/crontab)
Jan 18 21:34:01 mythtv /USR/SBIN/CRON[12958]: (root) CMD (/usr/local/bin/babysit_backend.sh >>/var/log/mythtv/babysit_backend.log 2>&1)
Jan 18 21:35:01 mythtv /USR/SBIN/CRON[13042]: (root) CMD (/usr/local/bin/babysit_backend.sh >>/var/log/mythtv/babysit_backend.log 2>&1)


Thanks for the Great script should raise the WAF for sure.... :D

Andy

_________________
KnoppMyth R5.5
MBE: AMD64 3400+, K8N Neo4 Plat., 1Gig, Asus Extreme N6200, 320G pata, 2x320Gsata, 750Gsata, PVR-150 Retail w/Blaster
SBE: AMD XP2000, GA 7ZMMH, 1 Gig, XFX 256M 6200, 20 Gig, PVR-150 Retail w/Blaster
SBE: AMD Dur1800, 512M, PVR500


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 19, 2007 6:43 am 
Offline
Joined: Fri Nov 18, 2005 9:22 am
Posts: 777
Location: spencerport, ny (USA)
Interesting... What user were you when you inserted into crontab? I was root when I did mine. Maybe the "root" directive in the crontab entry is only needed if you add as another user such as mythtv?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 19, 2007 8:31 am 
Offline
Joined: Mon Nov 07, 2005 10:09 am
Posts: 153
thanks for the idea and script.

I installed it on my slave backend whose backend recorder seems to go offline periodically.

I thought running it every minute might be overkill if there is any significant resources used to run it. Any thoughts? My machine barely eeks out hd now.

Previously, i had been thinking about looking for a script that would run from the master backend to periodically check that all slave backends are online and if not start them. i hadn't really looked into it yet though. I guess this works better. Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 19, 2007 8:39 am 
Offline
Joined: Sat Dec 24, 2005 11:33 am
Posts: 400
Location: Kitsap Peninsula, Wa., United States
Thornsoft wrote:
Quote:
What user were you when you inserted into crontab?


I was root when I installed this. I did notice when I went in to fix it, my Crontab lists the user name as one of the parameters that is what I guessed I needed to fix to make this work for me.

Anyway it works and that is a good thing....

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 19, 2007 9:00 am 
Offline
Joined: Fri Nov 18, 2005 9:22 am
Posts: 777
Location: spencerport, ny (USA)
randomhtpcguy wrote:
I thought running it every minute might be overkill if there is any significant resources used to run it. Any thoughts? My machine barely eeks out hd now.

It takes hardly any time to run, and doesn't launch anything bigger than "ps" unless the process is down. I don't think it would even have an impact if it ran every second.


Top
 Profile  
 
 Post subject: Crontab
PostPosted: Fri Jan 19, 2007 9:50 am 
Offline
Joined: Tue Jun 21, 2005 6:09 pm
Posts: 57
Could anyone point me in the direction of how to add this script to Crontab I have run it and it definetly fixed the problem I had with my backend going down.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 19, 2007 9:55 am 
Offline
Joined: Mon Nov 07, 2005 10:09 am
Posts: 153
follow the instructions at the top.

to add lines to crontab

login as root and type:

Code:
crontab -e


add the line from above

then exit and yes to save

that's it


Top
 Profile  
 
 Post subject: Crontab
PostPosted: Fri Jan 19, 2007 9:57 am 
Offline
Joined: Tue Jun 21, 2005 6:09 pm
Posts: 57
Thanks for the quick reply :lol:


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 19, 2007 10:21 am 
Offline
Joined: Fri Nov 18, 2005 9:22 am
Posts: 777
Location: spencerport, ny (USA)
Here's my favorite crontab tip:
Use a crontab.txt file, it's just safer. Here's how.
As root:

Go to the root home directory:
Code:
cd /root

Dump the existing crontab into crontab.txt
Code:
crontab -l > crontab.txt

Edit the file, I use vi.
Code:
vi crontab.txt

Now load the crontab.txt back into crontab.
Code:
crontab crontab.txt


Now verify the changes by listing the crontab:
Code:
crontab -l


Benefits: You have a backup if something goes wrong, and you can use any editor. To me, it just feels safer. And you can include it in the backup list, so it gets backed up. See TJC's backup notes.

--
Chris


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 23, 2007 6:50 pm 
Offline
Joined: Mon Nov 07, 2005 10:09 am
Posts: 153
For some reason, this doesn't work for me on my slave backend.

I think it is because the myth-backend needs to be restarted while the database and mythtv-backend on the master is running.

If i reboot the master including the master myth-backend, i have to restart the slave myth-backend for the frontends to recognize the recorders on the slave backend as available for recording.

After a master reboot, the slave myth-backend stays online but the frontends for some reason think the slave backend capture card is unavailable.

pretty confusing.


Top
 Profile  
 
 Post subject: crontab sanity check
PostPosted: Sun Jan 28, 2007 11:06 am 
Offline
Joined: Tue Mar 28, 2006 8:26 pm
Posts: 804
Location: Minneapolis, MN
I just looked in the /etc/crontab file and it looks different than I used to see in releases R5C7 and R5D1 - the /usr/local/bin/mythrename.pl script isn't being called anymore, for example.

By the way, the suggested crontab commands don't work in R5E50.
Code:
# cd /root
# crontab -l
and nothing was listed.
Code:
# cd /root
# crontab -e
and a text editor with an empty window appeared.
So, it would appear that these old crontab commands don't work in R5E50.

So, my belief is that /etc/crontab is the correct place to insert the line?
Code:
* * * * * /usr/local/bin/babysit_backend.sh >>/var/log/mythtv/babysit_backend.log 2>&1

If so, my current /etc/crontab file looks like this:
Code:
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file.
# This file also has a username field, that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
* * * * *  /usr/local/bin/babysit_backend.sh >>/var/log/mythtv/babysit_backend.log 2>&1
#

Look correct?

_________________
KnoppMyth R5.5, Asus A8N-VM CSM (nvidia 6150 onboard video), AMD Athlon 64 dual-core 4200+, two 1GB sticks DDR 400, HD-3000 HDTV card, PVR-150 card, Iguanaworks RS-232 IR receiver/transmitter, Pioneer DVR-110 DVD burner


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 50 posts ] 
Go to page 1, 2, 3, 4  Next



All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 14 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu