26332 total geeks with 3498 solutions
Recent challengers:
  • krc bonus 5 - 12:32PM
  • krc bonus 23 - 11:03AM
  • krc bonus 12 - 08:08AM
 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
MaxMouse
It's Friday... That's good enough for me!
CodeX
non stop lolz here but thats soon to end thanks to uni, surely the rest of the world is going good?
stabat
how things are going guys? Here... boring...
CodeX
I must be going wrong on the password lengths then, as long as it was done on ECB
MaxMouse
lol... the key is in hex (MD5: of the string "doit" without the "'s) and is in lower case. Maybe i should have submitted this as a challenge!

Donate
Donate and help us fund new challenges
Donate!
Due Date: Jun 30
June Goal: $40.00
Gross: $0.00
Net Balance: $0.00
Left to go: $40.00
Contributors


News Feeds
The Register
Ex-Systemax veep
charged with $230m
fraud
Roving IT
contractors and
private landlords
are my heroes -
here"s why
Wi-Fi Alliance
takes grid place,
revs engine in race
to 802.11ac
Julian Assange: I"m
quite happy to
sleep on Ecuador"s
sofa FOREVER
Supercomputer sage
Cray musters Lustre
cluster storage
hustler
Sneaky Seagate
slips "world"s
fastest" enterprise
disk mutant into
the wild
Hey mobile firms:
About that Android
thing... Did Google
add a lockout
clause?
PC makers REALLY
need Windows 8.1 to
walk on water - but
guess what?
Norks taunt, yank
Yanks" crank over
PRISM: US is
"rights abuse
kingpin"
Washout 2012
summer, melty
Greenland "nothing
to do with Arctic
ice or warm oceans"
Slashdot
Lobster, a New Game
Programming
Language, Now
Available As Open
Source
Google"s Crazy Lack
of Focus: Is It
Really Serious
About Enterprise?
Cat-like Robot Runs
Like the Wind
Revisiting Amdahl"s
Law
Altering Text In
eBooks To Track
Pirates
NVIDIA To License
Its GPU Tech
MySQL Man Pages
Silently Relicensed
Away From GPL
Verizon Accused of
Intentionally
Slowing Netflix
Video Streaming
Oculus Rift Raises
Another $16 Million
KWin Maintainer:
Fanboys and Trolls
Are the Cancer
Killing Free
Software
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 12827 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