Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm not too sure how to change the Apache script to do that (not too conversant with Linux etc).
My Apache script follows.... would you be able to suggest the appropriate lines of code to run /tomcat_all once http is running please?
Many thanks!
Max
#!/bin/bash
#
# Startup script for the Apache Web Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# processname: httpd
# pidfile: /var/run/httpd.pid
# config: /etc/httpd/conf/access.conf
# config: /etc/httpd/conf/httpd.conf
# config: /etc/httpd/conf/srm.conf
# Source function library.
. /etc/rc.d/init.d/functions
# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""
# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache2/bin/apachectl
httpd=/usr/local/apache2/bin/httpd
prog=httpd
RETVAL=0
# Find the installed modules and convert their names into arguments httpd
# can use.
moduleargs() {
moduledir=/usr/lib/apache
moduleargs=`
/usr/bin/find ${moduledir} -type f -perm -0100 -name "*.so" | env -i tr '[:lower:]' '[:upper:]' | awk '{\
gsub(/.*\//,"");\
gsub(/^MOD_/,"");\
gsub(/^LIB/,"");\
gsub(/\.SO$/,"");\
print "-DHAVE_" $0}'`
echo ${moduleargs}
}
# The semantics of these two functions differ from the way apachectl does
# things -- attempting to start while running is a failure, and shutdown
# when not running is also a failure. So we just do it the way init scripts
# are expected to behave here.
start() {
echo -n $"Starting $prog: "
daemon $httpd `moduleargs` $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/httpd
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd /var/run/httpd.pid
}
reload() {
echo -n $"Reloading $prog: "
killproc $httpd -HUP
RETVAL=$?
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f /var/run/httpd.pid ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac
Any easy way to do it is just to add a call to your script to /etc/rc.local. It's often best to use a full-fledged start/stop script, tohugh, so the service can be stopped cleanly on boot (by default, it is just terminated. I suspect Tomcat cleans itself up nicely when sent the TERM signal, but some things don't. In any case, the /etc/rc.local should work for starters.
BTW, Red Hat 7.1 is ancient. If you're looking at running a network Web server, you ought to upgrade to something current to take advantage of software improvements, security patches, etc.
Thanks for the advice. Yes, I'll look at upgrading my version of RedHat.
Re starting Tomcat, and shutting down, I kind of know that these processes are controlled via scripts in the /rc.d/init.d, /rc.d/rc0.d (etc) directories - I note they are named things like "K15httpd" and so on.
Would you be able to suggest which of the rc?.d directories I should put the start and stop Tomecat scripts, and what prefix I should use.
My apologies if these are rather 'dumb' questions...
Basically, the SXXservice (where XX is some number from 00-99) are symlinks to a "master" script in /etc/rc.d/init.d. When your Linux system boots, it is configured to go into a particular runlevel, generally 3 or 5, but it can vary by distro. To figure it out, look for a line like "id:N:initdefault:" in /etc/inittab. The N is a number, and that is the default runlevel. The scripts that control that runlevel are in the /etc/rc.d/rcN.d directory (again N is the runlevel number). When the runlevel is entered, All of the S scripts are called in numerical order with the argument of "start", which effectively calls /etc/rc.d/init.d/service start.
You can use chkconfig to easily manage these scripts. Read its man page "man chkconfig" for details. Note that this advice only applies to distros that use System V style init (most do, including Red Hat, but a few such as Slackware use BSD style init scripts).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.