简体   繁体   中英

How run a shell script from another shell script

I have recently install tomcat8 on Ubuntu. It is located at /opt/tomcat/apache-tomcat-8.0.36/bin and need to run ./shutdown.sh and ./startup.sh manually. Can anybody suggest me a shell scrip that can do startup, shutdown and even restart servers ? Thanks in advance.

this can help you

#!/bin/bash
start() {
/opt/tomcat/apache-tomcat-8.0.36/bin/startup.sh  
}

stop() {
/opt/tomcat/apache-tomcat-8.0.36/bin/shutdown.sh 
}

case "$1" in 
    start)
       start
       ;;
    stop)
       stop
       ;;
    restart)
       stop
       start
       ;;
    *)
       echo "Usage: $0 {start|stop|restart}"
esac

exit 0 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM