22858 total geeks with 3297 solutions
Recent challengers:
best bread maker
 Welcome, you are an anonymous user! [register] [login] Get a yourname@osix.net email address 

Articles

GEEK

User's box
Username:
Password:

Forgot password?
New account

Shoutbox
sefo
anilg, new comments are deleted automaticall y because of some abuse recently
anilg
this is plain wierd. I submitted comments twice to article 950, and they dont seem to be there. Something wrong with the comment code?
CodeX
shout-boxes in general are old + the staff thing happened to everyone after an issue 2 months ago
anilg
/me is no longer staff :(
anilg
Also, osix's shoutbox predated twitter. Heh.

Donate
Donate and help us fund new challenges
Donate!
Due Date: Jul 31
July Goal: $40.00
Gross: $0.00
Net Balance: $0.00
Left to go: $40.00
Contributors


News Feeds
The Register
UK.gov sticks to IE
6 cos it"s more
"cost effective",
innit
T-Mobile UK pumps
out the iPhone 4
Polaroid 300
instant print
camera
NatWest dumps O2
Money
YouTube ups video
time limit
Alleged expenses
fiddlers to face
justice
Nude trampolinist
bounces free from
court
Nexus One phone
rockets to 28,000ft
UK.gov drops £6m on
Google
Fake Firefox update
used to sling
scareware
Slashdot
British ISPs Favour
Well-Connected
Customers
"Bizarre"
Nanobubbles Found
In Strained
Graphene
1-in-1,000 Chance
of Asteroid Impact
In
...
2182?
2 Chinese ISPs
Serve 20% of World
Broadband Users
World"s Fastest
Hybrid OK"d For
Production
Sometimes It"s OK
To Steal My Games
Thermoelectrics
Could Let You Feel
the Heat In Games
KDE SC 4.7 May Use
OpenGL 3 For
Compositing
Perl 6, Early, With
Rakudo Star
Internal Costs Per
Gigabyte —
What Do You Pay?
Article viewer

Check is Sabnzbd process is running and restart if neccessary



Written by:bb
Published by:bb
Published on:2010-01-13 11:11:02
Topic:Linux
Search OSI about Linux.More articles by bb.
 viewed 2807 times send this article printer friendly

Digg this!
    Rate this article :
A bash script to check if the sabnzbd usenet program is running on a linux environment, and restart it if it has stopped or died.

Create a new script with the following...

#!/bin/bash
# Sabnzbd Process Monitor
# Restart Sabnzbd When It Goes Down
# ----------------------------------------------------------
# This script requires you have setup sab as a init.d
# daemon - http://wiki.sabnzbd.org/install-as-a-unix-daemon
# ----------------------------------------------------------
STOP="/etc/init.d/sabnzbd stop"
START="/etc/init.d/sabnzbd start"
 
#path to pgrep command (including the -f argument required)
PGREP="/usr/bin/pgrep -f"
 
# Sab daemon name,
SABPROC="SABnzbd"
 
# find pid
$PGREP ${SABPROC}
 
if [ $? -ne 0 ] # if not running
then
 # restart
 $STOP
 $START
fi


Set cronjob as follows:

*/5 * * * * /path/to/script.sh >/dev/null 2>&1


Did you like this article? There are hundreds more.

Comments:
Anonymous
2010-01-20 23:36:43
pretty (c)rude way of doing it.

quite wasteful on processes. wouldn't adding it to inittab, or using other process monitoring ...

now we have the cron daemon continuously starting bash, running a script, that starts pgrep, and if not running launches a crappy sh script, ... you like cycling through pids ? :)


bb
2010-01-28 16:33:40
sounds like some cool ideas there redore, why not expand the idea - so it becomes actually useful for someone wishing to improve.
asmodai
2010-03-22 06:42:01
I really don't know where this entire 'wasteful on processes' thing comes from. Having a script run through cron is actually perfectly fine, and in some cases is actually better than abusing /etc/inittab because:

1) /etc/inittab requires root and starts the process as root... not a good thing if the process in question doesn't run as another uid.

2) /etc/inittab will sure respawn the process... but if the process has a major problem, then init will hammer the system by trying to restart the process continuously until it decides to give up. Guess what the way around this is? Yes, a script... which would spawn stuff like pgrep.

It could be done using launchd, SMF et al, sure... but then management would be limited to the super user.

Do you actually know the highest PID number a modern Unix system can have? The entire thing is just moot when one considers that number is fairly big these days.

However, that being said... for some things, running from /etc/inittab (or via SMF, given Solaris doesn't like one editing /etc/inittab) is actually better, if one doesn't require sanity checks and one knows for a fact that restarts from inittab will not fail -- assumption is the bane of all Unix sysadmins.
Anonymously add a comment: (or register here)
(registration is really fast and we send you no spam)
BB Code is enabled.
Captcha Number:


Blogs: (People who have posted blogs on this subject..)
bb
start svn on system boot in debian on Tue 21st Jul 10am
http://linux.justinhartman.com/Startup_S cript_for_Subversion I found this a really simple explanation of how to start svn when the server boots
bb
SSHFS: Super Easy File Access over SSH on Wed 18th Feb 1pm
This was really useful, and worked great to communicate between servers. http://www.linuxjournal.com/article/8904 Thanks to gabbs
bb
hellanzb nzb news downloader for NSLU2 on Tue 22nd May 7pm
Someone introduced me to the joyful NZB file recently. Its truly a wonderful invention, and allows my to explore usenet binary grabbing using my NSLU2. as previous nntp readers id tried made the process too painful. So simply .... 1) apt-get inst
bb
edna mp3 streaming for nslu2 on Wed 9th May 11am
I've been streaming music from my home NSLU2 server for a while now using mt-daapd (firefly) which is an ITunes server for linux. I can connect to my home network from work using ITunes and a little daap proxy app called rendevous. My friend was doing
Adnurak
How to choose the right Linux Distro on Thu 9th Nov 7pm
This is mainly for new users who want to try out Linux for the first time, but try it out if you're experienced in Linux anyway, it's kinda fun. What with all these different distributions of Linux that you hear about all the time, it's hard to choose
ketan404
my blog on Thu 9th Nov 6am
http://ketan404.blogspot.com
bb
Tweaking Apache and Mysql for Low Memory on Fri 20th Oct 11am
i implemented this to tweak my apache/mysql for better performance on my NSLU2. Hard to tell if its helping much though ;-) Mysql really doesnt run too well with apache on NSLU2 so I dont use it for much. http://www.unixshell.com/wiki/index.php/ Optimiz
Adnurak
Fate - A Linux Security Simulation Written in C++ on Fri 20th Oct 6am
Fate is a simulation of a Linux system written in C++ and meant for DOS (runs fine in winxp and winme by just doubleclicking) that according to the creator, m101, shows you the basics of security in different Linux systems, including but not limited to, M
bb
Article on building rtorrent for arm5vtel NSLU2 with debianslug on Thu 19th Oct 7am
I wrote an article today on my efforts at compiling rtorrent for debianslug. its here ... Article on building rtorrent/libtorrent for arm5vtel NSLU2 with littleendian debianslug
bb
How to mount .iso file on NSLU2 running debianslug on Tue 19th Sep 12pm
If like me your running debianslug on an NSLU2 and you'd like to mount an iso file so it can be directly streamed to Xbox Media Centre (its a beautiful solution isnt it!) then simply do the following. Ensure you have loop support in your debianslug k

Test Yourself: (why not try testing your skill on this subject? Clicking the link will start the test.)
Linux Test Simple by a13x4nd7u

This is a simple Linux commands test.
Linux Quiz by abhijangda

Trivia about your favorite OS
Linux Administration by typedeaF

Testing your knowledge of Linux administration tools, very light shell scripting, and good high level understanding of how the OS works at the user level. Anyone who has worked with Linux for 1-3 years should do good.
Linux Commands (Part 1) by nirus

If you think you know the linux command-line then this test is for you. For reference purposes, it is based on Debian/GNU Linux with a BASH Shell.


     
Your Ad Here
 
Copyright Open Source Institute, 2006