Bash script for crontab

Talk about pretty much anything here, but DO NOT USE FOR SUPPORT.

Moderator: Supporters

Locked
SourceX
Posts: 4
Joined: Thu Apr 01, 2004 11:39 pm

Bash script for crontab

Post 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.
aquanight
Official supporter
Posts: 862
Joined: Tue Mar 09, 2004 10:47 pm
Location: Boise, ID

Post 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
Syzop
UnrealIRCd head coder
Posts: 2112
Joined: Sat Mar 06, 2004 8:57 pm
Location: .nl
Contact:

Post by Syzop »

See the ircdcron dir (ircdcron/ircdchk).
SourceX
Posts: 4
Joined: Thu Apr 01, 2004 11:39 pm

Post by SourceX »

Wow i'm an idiot, thanks.
codemastr
Former UnrealIRCd head coder
Posts: 811
Joined: Sat Mar 06, 2004 8:47 pm
Location: United States
Contact:

Post 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.
-- codemastr
w00t
Posts: 1136
Joined: Thu Mar 25, 2004 3:31 am
Location: Nowra, Australia

On Linux...

Post by w00t »

Wouldnt ps aux | grep unrealircd do the trick? if it returns null, it aint running... Just a thought. :lol:
-ChatSpike IRC Network [http://www.chatspike.net]
-Denora Stats [http://denora.nomadirc.net]
-Omerta [http://www.barafranca.com]
codemastr
Former UnrealIRCd head coder
Posts: 811
Joined: Sat Mar 06, 2004 8:47 pm
Location: United States
Contact:

Post 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.
-- codemastr
aquanight
Official supporter
Posts: 862
Joined: Tue Mar 09, 2004 10:47 pm
Location: Boise, ID

Post 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).
Nugget
Posts: 3
Joined: Mon Apr 12, 2004 4:54 am
Location: Austin Texas USA
Contact:

Post 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.
AngryWolf
Posts: 554
Joined: Sat Mar 06, 2004 10:53 am
Location: Hungary
Contact:

Post by AngryWolf »

Or an alternative solution is to type ps x | grep ircd | grep -v grep.
Locked