Page 1 of 1
Bash script for crontab
Posted: Thu Apr 01, 2004 11:42 pm
by SourceX
Any handy bash scripters here who could write up a script to check if the unrealircd process is running, if its not start it, if it is then exit the script Or does anyone know of any already exsisting? My purpose is to add a crontab job for this script.
Posted: Fri Apr 02, 2004 12:10 am
by aquanight
I believe the ls command will return an error value if no files match the options. Something like?
Code: Select all
cd /ircddirectory
ls ircd.pid > /dev/null || unreal start
Posted: Fri Apr 02, 2004 12:17 am
by Syzop
See the ircdcron dir (ircdcron/ircdchk).
Posted: Fri Apr 02, 2004 12:27 am
by SourceX
Wow i'm an idiot, thanks.
Posted: Fri Apr 02, 2004 3:25 am
by codemastr
I believe the ls command will return an error value if no files match the options. Something like?
That will likely be true, but the existence of ircd.pid does not mean Unreal is running. I don't believe Unreal ever destroys ircd.pid, so all that file's existence signifies is that at one point in time Unreal was running.
On Linux...
Posted: Fri Apr 02, 2004 5:15 am
by w00t
Wouldnt ps aux | grep unrealircd do the trick? if it returns null, it aint running... Just a thought.

Posted: Fri Apr 02, 2004 4:59 pm
by codemastr
No it wouldn't. First off, it doesn't even get listed as "unrealircd" secondly, that just says _an_ Unreal is running. If you're on a shell account, there might be 10 ircds running. It doesn't mean your's is running.
Posted: Wed Jun 09, 2004 3:51 am
by aquanight
Sorry to dig up this old thing...
ps x, by itself, should show "unhooked" processes (tty-less) that belong to the current user. Unless there are 500 people using the same login... using that should only show your ircd(s).
Posted: Mon Jun 14, 2004 4:56 pm
by Nugget
A useful trick if you're going to go the "ps | grep" route is to use egrep to avoid matching the grep itself.
Casual experimenting will lead to the discovery that "ps ux | grep ircd" will catch itself about half the time. Instead, I prefer to use something like this:
Code: Select all
ps -uxww | egrep "[i]rcd" || /usr/local/ircd/ircd &
Using the brackets in an egrep will make the grep not match itself which will yield reliable results.
Posted: Mon Jun 14, 2004 5:07 pm
by AngryWolf
Or an alternative solution is to type ps x | grep ircd | grep -v grep.