Page 1 of 2

How to start xinetd after server reboot

Posted: Wed May 11, 2016 12:41 pm
by Shawn L
Hi,

One of our servers was rebooted yesterday, but somehow the xinetd was not start after reboot. What can I do to make it automatically start each time after server reboot? Thanks in advance.

Here is the output of chkconfig:

Code: Select all

...
xinetd          0:off   1:off   2:off   3:on    4:on    5:on    6:off
...
xinetd based services:
        chargen-dgram:  off
        chargen-stream: off
        daytime-dgram:  off
        daytime-stream: off
        discard-dgram:  off
        discard-stream: off
        echo-dgram:     off
        echo-stream:    off
        nrpe:           on
        rsync:          off
        tcpmux-server:  off
        time-dgram:     off
        time-stream:    off

Re: How to start xinetd after server reboot

Posted: Wed May 11, 2016 2:21 pm
by bwallace
I think you're ok actually. Here is the output of chkconfig from a test machine here that's been running for
uptime 12:44:34 up 16 days

Code: Select all

xinetd          0:off   1:off   2:off   3:on    4:on    5:on    6:off

xinetd based services:
        chargen-dgram:  off
        chargen-stream: off
        daytime-dgram:  off
        daytime-stream: off
        discard-dgram:  off
        discard-stream: off
        echo-dgram:     off
        echo-stream:    off
        nrpe:           on
        nsca:           on
        tcpmux-server:  off
        time-dgram:     off
        time-stream:    off

Re: How to start xinetd after server reboot

Posted: Thu May 12, 2016 7:57 am
by Shawn L
But, in fact, the xinetd was not started after reboot. Do you have any idea what could cause this problem? This morning, another server was rebooted, and xinetd was not running on that server.

Code: Select all

[root@server ~]# service xinetd status
xinetd dead but pid file exists
[root@server ~]# service xinetd restart
Stopping xinetd:                                           [FAILED]
Starting xinetd:                                           [  OK  ]
[root@server~]# service xinetd status
xinetd (pid  29095) is running...

Re: How to start xinetd after server reboot

Posted: Thu May 12, 2016 10:20 am
by hsmith
Which distro?

Re: How to start xinetd after server reboot

Posted: Thu May 12, 2016 10:26 am
by lmiltchev
Do you find any clues in the /var/log/messages?

Run the following commands and show the output in code wraps:

Code: Select all

echo $PATH
cat /etc/init.d/xinetd

Re: How to start xinetd after server reboot

Posted: Thu May 12, 2016 1:02 pm
by gormank
If the pid file existed after a restart, the service died unexpectedly. Since the file existed, the service didn't restart.
The question is not how to make it start, but why didn't it shut down correctly. We could also ask why a starting service doesn't check the pid and verify that a matching process exists, but that's the next step.

Re: How to start xinetd after server reboot

Posted: Thu May 12, 2016 3:02 pm
by Shawn L
The dsitro is RHEL 6.6.

In the message file, I saw lots of kernel IO errors. Could that be the problem?

Re: How to start xinetd after server reboot

Posted: Thu May 12, 2016 3:20 pm
by rkennedy
Is your VM running off a SAN or NAS? This could be an issue. Please post the output @lmiltchev mentioned -

Code: Select all

echo $PATH
cat /etc/init.d/xinetd
Yes, IO errors can be fatal. Do you know why the machine was shutdown as @gormank mentioned?

Re: How to start xinetd after server reboot

Posted: Fri May 13, 2016 9:52 am
by Shawn L

Code: Select all


[root@server~]# $PATH
-bash: /usr/lib64/qt-3.3/bin:/opt/jdk_jboss/bin:/opt/jdk_jboss/jre/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/var/cfengine/bin:/root/bin: No such file or directory

[root@server~]# cat /etc/init.d/xinetd
#!/bin/bash
#
# xinetd        This starts and stops xinetd.
#
# chkconfig: 345 56 50
# description: xinetd is a powerful replacement for inetd. \
#              xinetd has access control mechanisms, extensive \
#              logging capabilities, the ability to make services \
#              available based on time, and can place \
#              limits on the number of servers that can be started, \
#              among other things.
#
# processname: /usr/sbin/xinetd
# config: /etc/sysconfig/network
# config: /etc/xinetd.conf
# pidfile: /var/run/xinetd.pid


### BEGIN INIT INFO
# Provides:
# Required-Start: $network
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: start and stop xinetd
# Description: xinetd is a powerful replacement for inetd. \
#              xinetd has access control mechanisms, extensive \
#              logging capabilities, the ability to make services \
#              available based on time, and can place \
#              limits on the number of servers that can be started, \
#              among other things.
### END INIT INFO

PATH=/sbin:/bin:/usr/bin:/usr/sbin

# Source function library.
. /etc/init.d/functions

# Get config.
test -f /etc/sysconfig/network && . /etc/sysconfig/network

# More config

test -f /etc/sysconfig/xinetd && . /etc/sysconfig/xinetd

RETVAL=0

prog="xinetd"

start(){
    [ -f /usr/sbin/xinetd ] || exit 5
    [ -f /etc/xinetd.conf ] || exit 6
    # this is suitable way considering SELinux is guarding write
    # access to PID file
        [ $EUID -eq 0 ] || exit 4

    echo -n $"Starting $prog: "

# Localization for xinetd is controlled in /etc/synconfig/xinetd
    if [ -z "$XINETD_LANG" -o "$XINETD_LANG" = "none" -o "$XINETD_LANG" = "NONE" ]; then
        unset LANG LC_TIME LC_ALL LC_MESSAGES LC_NUMERIC LC_MONETARY LC_COLLATE
    else
        LANG="$XINETD_LANG"
        LC_TIME="$XINETD_LANG"
        LC_ALL="$XINETD_LANG"
        LC_MESSAGES="$XINETD_LANG"
        LC_NUMERIC="$XINETD_LANG"
        LC_MONETARY="$XINETD_LANG"
        LC_COLLATE="$XINETD_LANG"
        export LANG LC_TIME LC_ALL LC_MESSAGES LC_NUMERIC LC_MONETARY LC_COLLATE
    fi
    unset HOME MAIL USER USERNAME
    daemon $prog -stayalive -pidfile /var/run/xinetd.pid "$EXTRAOPTIONS"
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/xinetd
    return $RETVAL
}

stop(){
    [ -f /usr/sbin/xinetd ] || exit 5
    [ -f /etc/xinetd.conf ] || exit 6
    # this is suitable way considering SELinux is guarding write
    # access to PID file
        [ $EUID -eq 0 ] || exit 4

    echo -n $"Stopping $prog: "
    killproc -p /var/run/xinetd.pid $prog
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/xinetd
    return $RETVAL

}

reload(){
    [ -f /usr/sbin/xinetd ] || exit 5
    [ -f /etc/xinetd.conf ] || exit 6

    echo -n $"Reloading configuration: "
    killproc $prog -HUP
    RETVAL=$?
    echo
    return $RETVAL
}

restart(){
    stop
    start
}

condrestart(){
    if [ -e /var/lock/subsys/xinetd ] ; then
        restart
        RETVAL=$?
        return $RETVAL
    fi
    RETVAL=0
    return $RETVAL
}


# See how we were called.
case "$1" in
    start)
        start
        RETVAL=$?
        ;;
    stop)
        stop
        RETVAL=$?
        ;;
    status)
        status $prog
        RETVAL=$?
        ;;
    restart)
        restart
        RETVAL=$?
        ;;
    reload|force-reload)
        reload
        RETVAL=$?
        ;;
    condrestart|try-restart)
        condrestart
        RETVAL=$?
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
        RETVAL=2
esac

exit $RETVAL

Re: How to start xinetd after server reboot

Posted: Fri May 13, 2016 10:24 am
by Shawn L
I am not managing that server, I am not pretty sure why they rebooted it.