Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Here's the autorun script, which i use -

#!/bin/sh

    # description: Tomcat start/stop script
    # chkconfig:

    TOMCAT_PATH=/java/apache-tomcat-7.0.32/bin
    TOMCAT_START=$TOMCAT_PATH/startup.sh
    TOMCAT_STOP=$TOMCAT_PATH/shutdown.sh

    start()
    {
    if [ -x ${TOMCAT_START} ]; then
    echo "Starting tomcat server..."
    ${TOMCAT_START} &
    else
    echo "Cannot start tomcat server"
    fi
    }

    stop()
    {
    if [ -x ${TOMCAT_STOP} ]; then
    echo "Stopping tomcat server"
    ${TOMCAT_STOP} &
    else
    echo "Cannot stop tomcat server..."
    fi
    }

    restart()
    {
    stop
    sleep 10
    start
    }

    case "$1" in
    'start')
    start
    ;;
    'stop')
    stop
    ;;
    'restart')
    restart
    ;;
    *)
    echo "Please supply an argument [start|stop|restart]"
    esac

I put it in -

/etc/rc.d/init.d/

I added it to the startup:

/sbin/chkconfig --add --level 345 tomcat

But when i reboot the system, watch the logs and see -

catalina.out:

...
INFO: Stopping service Catalina
jan 03, 2013 6:09:04 PM hudson.util.CharacterEncodingFilter destroy
INFO: CharacterEncodingFilter destroyed.
jan 03, 2013 6:09:04 PM javax.jmdns.impl.tasks.state.DNSStateTask run
WARNING: Canceler(www-...-ru.local.).run() exception 
java.io.IOException: Invalid argument
    at java.net.PlainDatagramSocketImpl.send(Native Method)
    at java.net.DatagramSocket.send(DatagramSocket.java:676)
    at javax.jmdns.impl.JmDNSImpl.send(JmDNSImpl.java:1537)
    at javax.jmdns.impl.tasks.state.DNSStateTask.run(DNSStateTask.java:131)
    at java.util.TimerThread.mainLoop(Timer.java:555)
    at java.util.TimerThread.run(Timer.java:505)

The process does not start.

But if i execute the command -

/etc/rc.d/init.d/tomcat start

The process starts well.

Why does it not start automatically?

Thanks!

share|improve this question
1  
don't you need to add some kind of pre-requisit? It's failing on java.net most likely it's trying to start when your network services are not up yet. –  BitsOfNix Jan 3 '13 at 15:23
    
Thanks for the reply, Alexandre Alves! Yes, i thought about it. I am looking for a solution. –  Alexey Jan 3 '13 at 15:27
    
add a symlink in /etc/rc[3-5].d/S90tomcat pointing to your start script and try again. I'm assuming that Mandriva still uses the start scripts as Redhat and not the new ones. I choose a S90 to "ensure" that network will be up when it is called. –  BitsOfNix Jan 3 '13 at 15:33
    
Ok, now i'll try to do it. Thank you! –  Alexey Jan 3 '13 at 15:37
1  
@ivanov-void Can you post output of who -r and ls /etc/rc.d/rc<rl>.d/ for the appropriate runlevel after the machine starts. –  Karlson Jan 4 '13 at 15:02
show 2 more comments

1 Answer 1

up vote 0 down vote accepted

I changed a little shell-script:

#!/bin/sh
#
# Startup script for Tomcat
#

JAVA_HOME="/usr/java/jdk1.7.0_09" ;
JRE_HOME=/usr/java/jdk1.7.0_09/jre;
CATALINA_HOME=/java/tomcat-7.0.27;
export JAVA_HOME && export JRE_HOME &&$CATALINA_HOME/bin/startup.sh &&$CATALINA_HOME/bin/shutdown.sh

case "$1" in
start)
echo -n "Starting Tomcat"
su - tomcat -c $CATALINA_HOME/bin/startup.sh
;;
stop)
echo -n "Stopping Tomcat"
su - tomcat -c $CATALINA_HOME/bin/shutdown.sh
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac

exit 0

Then put it in

/etc/rc.d/init.d

Added the rights to run:

# chmod +x /etc/init.d/ tomcat

Added symbolic links:

ln -s /etc/init.d/tomcat /etc/rc0.d/K91tomcat
ln -s /etc/init.d/tomcat /etc/rc1.d/K91tomcat
ln -s /etc/init.d/tomcat /etc/rc2.d/S91tomcat
ln -s /etc/init.d/tomcat /etc/rc3.d/S91tomcat
ln -s /etc/init.d/tomcat /etc/rc4.d/S91tomcat
ln -s /etc/init.d/tomcat /etc/rc5.d/S91tomcat
ln -s /etc/init.d/tomcat /etc/rc6.d/K91tomcat

Now all is well.

reboot;

catalina.out:

...
INFO: Server startup in 113947 ms

Thanks a lot!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.