Bash script for crontab
Moderator: Supporters
Bash script for crontab
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.
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
-
- Former UnrealIRCd head coder
- Posts: 811
- Joined: Sat Mar 06, 2004 8:47 pm
- Location: United States
- Contact:
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.I believe the ls command will return an error value if no files match the options. Something like?
-- codemastr
On Linux...
Wouldnt ps aux | grep unrealircd do the trick? if it returns null, it aint running... Just a thought.
-ChatSpike IRC Network [http://www.chatspike.net]
-Denora Stats [http://denora.nomadirc.net]
-Omerta [http://www.barafranca.com]
-Denora Stats [http://denora.nomadirc.net]
-Omerta [http://www.barafranca.com]
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:
Using the brackets in an egrep will make the grep not match itself which will yield reliable results.
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 &