-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 10/29/2014 10:33 AM, Anthony Bungeroth wrote:
>
> I basically need a script to run automatically when I reboot the
> server. I have tried the various ways to get it to work in init.d
> and it's not working. When I go into init.d and run it manually
> it works though.
>
> I think it has something to do with the fact that to run the script
> manually I am logged in as root, whereas for it to run
> automatically it has to run in the background.
>
> I will include the script info in this email and see if you had an
> idea as to where the issue is.
>
> So in /etc/init.d, there is a script called Tomcat, here is the
> "start" portion of the script. Once again, when I run this
> manually while logged in as root it launches.
>
> #!/bin/sh # Apache Tomcat Startup Script # chkconfig 234 20 80
>
> JAVA_HOME=/opt/jdk1.6.0_45 CATALINA_HOME=/opt/tomcat
> TOMCAT_USER=tomcat
>
> start() { echo -n "Starting Tomcat: " su $TOMCAT_USER
> $CATALINA_HOME/bin/startup.sh sleep 2 }
>
> I tried creating a new script and putting that one in "rc.local".
> Here is the "rc.local" command:
>
> #!/bin/sh # # This script will be executed *after* all the other
> init scripts. # You can put your own initialization stuff in here
> if you don't # want to do the full Sys V style init stuff.
>
> su tomcat /opt/tomcat/bin/startup.sh
>
> This is a total rookie issue I am sure....but just in case you
> might be able to help with an easy enough fix, I would greatly
> appreciate it. I don't even know where to look for error logs to
> troubleshoot this. Thanks for any assistance. Anthony
> ________________________________ Anthony Bungeroth Systems
> Engineer
>
> p: 347-762-5863 (347-76 BLUME) f: 419-831-5614 e:
> [email protected] Our Blog<http://blogs.blumetech.com/>
> [blumetech] <http://www.blumetech.com>
> <http://www.blumetech.com>[blumetech]
> <http://www.aws-partner-directory.com/PartnerDirectory/PartnerDetail?Name=Blume+Technical+Consulting>
>
>
>
>
<http://www.aws-partner-directory.com/PartnerDirectory/PartnerDetail?Name=Blume+Technical+Consulting>
>
> This email and any files transmitted with it are confidential and
> intended solely for the use of the individual or entity to whom
> they are addressed. If you have received this email in error, you
> are directed not to read, disclose, reproduce, distribute,
> disseminate or otherwise use this transmission, and we also
> request that you immediately delete this message and its
> attachments, if any. Delivery of this message to any person other
> than the intended recipient(s) is not intended in any way to waive
> privilege or confidentiality. Finally, the recipient should check
> this email and any attachments for the presence of viruses;
> Blumetech accepts no liability for any damage caused by any virus
> transmitted by this email.
>
Anthony,
My relevant line looks like this (all one line of course):
$SU - $TOMCAT_USER -c "${CONFIG_OPTS} ${CAT_PID} ${TOMCAT_INSTANCE}
start" >> $SERVICE_LOG 2>&1
$SU - set to su for non-SELinux, runuser for SELinux
$TOMCAT_USER - Tomcat user
${CONFIG_OPTS} - CATALINA_HOME, CATALINA_BASE, JRE_HOME, etc.
${CAT_PID} - PID, not used in startup
${TOMCAT_INSTANCE} - Tomcat command based on CATALINA_HOME
$SERVICE_LOG - logs the start and stop of the service
I stuff all of the options in a file which is parsed and placed into
${CONFIG_OPTS}. I could probably use setenv.sh, but this way I have a
root-controlled (and versioned) configuration file for my service
configuration.
I use catalina.sh directly, which is buried in the ${TOMCAT_INSTANCE}
variable. This is so I can do start and stop with one command setup.
Based on that and using catalina.sh, your command line should probably
look like:
start() {
echo -n "Starting Tomcat: "
su - $TOMCAT_USER -c "{$CATALINA_HOME}/bin/catalina.sh start"
sleep 2
}
Make sure your permissions in $CATALINA_HOME are correct.
And your su might need to be runuser, depending on whether or not you
use SELinux.
. . . just my two cents
/mde/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQEcBAEBAgAGBQJUUUOsAAoJEEFGbsYNeTwtc30H+wYMoqdkvsnnVoxo/ettJVco
UgBuWJBVnyWAuHvmDytNnh6YmtWAzaAQDTtC3lHll25Po0lv0giORXRz8GGI3wlM
OJejGeCYj2sjPSOCSMv2DpSCaYn/nR9VD7TUbjM5wx1Co31lxbT3z2QDz/2LQFoI
yt/312hiaJERKRRAjHmmYKU1Za+dlpat6kNoCZBKgu1nDqML6gj0gENV0AhScZwp
tAAu0J275KR4prMGRJxsI9Et+w52ORCfcH00NURHnEv+4v15eWm2/egzerzGFxh7
20kwIukUqBaNVCab6+rvH8xuwCyNGJqiKb3sR87GB6iTi47p7rWhod40Ou9qWvA=
=BzOH
-----END PGP SIGNATURE-----
---
This email is free from viruses and malware because avast! Antivirus protection
is active.
http://www.avast.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]