1847279 Members
2563 Online
110263 Solutions
New Discussion

Re: Script / inetd

 
Junior C.
Frequent Advisor

Script / inetd

I want to check and see if inetd is running every hour. If not running start inetd.

This is what I have so far.

inedtrunning=$(ps -ef | grep inetd | grep /usr

if [[ -n ${inetdrunning} ]]
then
---------------------
else
---------------------
fi
unset inetdrunning

Thanks, for all help in advance
5 REPLIES 5
John Palmer
Honored Contributor

Re: Script / inetd

To cut out a grep:-

inetdrunning=$(ps -e|grep inetd)

if [[ -n ${inetdrunning ]];
...

I must confess however that I have never had a server where inetd died. I would be looking to HP to cure the problem if that was the case.

Regards,

John
James R. Ferguson
Acclaimed Contributor

Re: Script / inetd

Junior:

OOPS! Forgot the closing tick mark:

if (( `ps -ef|grep $WHAT|grep -c -v "grep $WHAT"` > 0 ))

...JRF...
James R. Ferguson
Acclaimed Contributor

Re: Script / inetd

Junior:

I'm not sure why you are worried that the superdaemon is/isn't running as it seems you would have/detect lots of problems if it wasn't.

However, one general way to test if a particular process is running is to do the following:

WHAT=inetd
if (( `ps -ef|grep $WHAT|grep -c -v "grep $WHAT" > 0 ))
then
echo "$WHAT running"
else
echo "$WHAT not running"
fi

...JRF...
Vikas Khator
Honored Contributor

Re: Script / inetd

You may want to add a entry in /etc/inittab so that it gets spawned if one isn't running already
Keep it simple
curt larson
Frequent Advisor

Re: Script / inetd

As has been mentioned here, inetd doesn't die. Look at what inetd has been patched for. You'll find that it hangs, blocks, loops out of control, issues timeouts, doesn't behave well under a heavy load, etc. Your method of checking for the process running will not catch any of these. And they happen often enough that HP has issued a patch for them. And the list doesn't include dieing unexpectedly, but that could be what the next patch is issued for.

I'd suggest using a method that will verify that inetd is acutally working. Such as running, telnet $(hostname) 13, which will return the system time. Although, you'll have to devise a method for testing. ie I don't know of a broken inetd that you can test against for error messages. Can a hung inetd be stopped and restarted? etc.

Using such a method will not only catch inetd not running, but other error conditions also.
nobody else has this problem