In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
How to write an automatic startup script under suse? I believe many inexperienced people don't know what to do about it. Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Know a lot about SUSE Linux, maybe you don't know much about it, it doesn't matter, here we discuss with each other, today we are talking about automatic startup in SUSE Linux Tomcat. I hope this article can be of some help to you, and I hope you can learn to start SUSE Linux Tomcat automatically. Add commands to the / etc/init.d/boot.local file. The corresponding file for the Red Hat system is / etc/rc.d/rc.local.
For commands or programs that run automatically when a Linux system starts, it is common to put them in / etc/rc.d/rc.local on rh-based linux systems. However, SuSE Linux does not have this file, and it is not recommended that consumers manage startup services in this way. It is recommended to use a formal way to manage service startup.
Some people will say that in a SuSE system, you can put it in / etc/init.d/boot.local, depending on the actual situation. Because the / etc/init.d/boot.local file of SuSE is started by the script of / etc/init.d/boot, and it is executed when the final boot script work is finished and is ready to enter the runlevel environment to execute each rc script. On the other hand, the / etc/rc.d/rc.local file of rh is executed in the last phase when each rc script is executed in the runlevel environment, so the level is different. If the program you want to run is suitable for execution before the runlevel service, you can put it in the boot.local file in SuSE linux.
However, if your service needs to be executed after entering runlevel, the formal practice under SuSE should be to write a rc script and put it in the / etc/init.d/ directory, and then use the chkconfig or inssev program to manage whether to enable and close the service project when a runlevel environment is powered on. The rc script can be written by referring to the ready-made script file in / etc/init.d/, and it should be easy to write your own version.
Create a start / stop script file
With the following script, you can make Tomcat run in Service mode.
#! / bin/bash
# chkconfig: 2345 10 90
# description: Starts and Stops the Tomcat daemon.
TOMCAT_HOME=/usr/local/tomcat/apache-tomcat-5.5.25
TOMCAT_START=$TOMCAT_HOME/bin/startup.sh
TOMCAT_STOP=$TOMCAT_HOME/bin/shutdown.sh
# necessary environment variables export
CATALINA_HOME=$TOMCAT_HOME
Export JAVA_HOME=/usr/java/jdk1.6.0_03
# source function library.
. / etc/rc.d/init.d/functions
# source networking configuration.
. / etc/rc.d/network
# check that networking is up.
["${NETWORKING}" = "no"] & & exit 0
# check for tomcat script
If [!-f $TOMCAT_HOME/bin/catalina.sh]
Then echo "Tomcat not valilable..."
Exit
Fi
Start () {
Echo-n "Starting Tomcat:"
Daemon $TOMCAT_START
Echo
Touch / var/lock/subsys/tomcat
}
Stop () {
Echo-n $"Shutting down Tomcat:"
Daemon $TOMCAT_STOP
Rm-f / var/lock/subsys/tomcat.pid echo
}
Restart () {
Stop
Start
}
Status () {
Ps ax-- width=1000 | grep "[o] rg.apache.catalina.startup.Bootstrap start" | awk'{printf $1 ""}'| wc | awk'{print $2}'> / tmp/tomcat_process_count.txt
Read line < / tmp/tomcat_process_count.txt
If [$line-gt 0]; then
Echo-n "tomcat (pid")
Ps ax-- width=1000 | grep "org.apache.catalina.startup.Bootstrap start" | awk'{printf $1 ""}'
Echo-n ") is running..."
Echo
Else
Echo "Tomcat is stopped"
Fi
}
Case "$1" in
Start)
Start
Stop)
Stop
Restart)
Stop
Sleep 3
Start
Status)
Status
*)
Echo "Usage: tomcatd {start | stop | restart | status}"
Exit 1
Esac
Exit 0
Save and set up the script file
Save the above script file in / etc/init.d and name it tomcat
Set the file properties of tomcat
# chmod axix tomcat
3. Set the service running level
Finally, set up the service to run with chkconfig
# chkconfig-add tomcat
The service is added successfully.
Then you can use chkconfig-list to view it, and custom services will appear in the list of services.
Note:
In the comment statement of the first two lines of the tomcat file, you need to include both chkconfig and description (make sure there are no spelling mistakes,), otherwise, when executing "chkconfig-- add tomcat", there will be an error message that "the tomcat service does not support chkconfig".
The line chkconfig indicates the default runlevel of startup and the priority of startup and stop. If the service is no longer started at any runlevel by default, the runlevel is replaced by -. In tomcat, it means that the script starts at run level 2, 3, 4, 5, with a start priority of 10 and a stop priority of 90.
The description line describes the service and can be commented across lines with "\". In this way, you will learn the automatic startup process of SUSE Linux Tomcat.
After reading the above, have you mastered how to write an automatic startup script under suse? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.