You can use upstart if you have that, with a .conf file. However unless you source the profile.d or wherever your environment variables are held do not use them in an init task!
On Wed, Oct 29, 2014 at 1:55 PM, Christopher Schultz < ch...@christopherschultz.net> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > > Anthony, > > On 10/29/14 1:33 PM, 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. > > That's good. > > > 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. > > /etc/init.d are not usually run "in the background". Most /etc/init.d > scripts are processed as "root" on boot, so that shouldn't matter. > > > 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 > > I'm not sure that's going to work. "man su". On my system, the command > comes first (with a "-c" switch), the username last. You might want to > consider using "sudo" instead of "su". > > > sleep 2 > > Sleep? Why? > > > } > > > > 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. > > Don't use rc.local. Use /etc/init.d/[whatever] > > Remember that /etc/init.d scripts aren't directly executed at boot: > you have to "ln -s" each script into /etc/rcX.d where X is the > runlevel number into which the machine is booting. > > Hope that helps, > - -chris > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1 > Comment: GPGTools - http://gpgtools.org > > iQIcBAEBCAAGBQJUUSooAAoJEBzwKT+lPKRYjLoQAMmtQ2fm12YbKDC6893mjO0T > Hf9oBBDxoBLxkIGu1LC/DUs3GQTGrer3IikNTdIfYzF66ULClD0qxziNbtLcEjtw > OLAIiA1cp0zMw2J5NTg5xacyVO8EH9yvKYlgjroLQBfwqK7woo58f4hnh91TkVTZ > uWwY1d/wt0iJ2nVeScQh9xGYonZkMeLpDFryG+ANAgXOomqzz7uRz52Tsfp46Q7f > 9laPkMRu8paNJ86TSZtr+fQ/NQhhWh+6F8rgqxf/FYwxwbWzN7hgleX4oAev0tTv > uM8lOz4tdWreKHMAXGGgrLY/55sCTdPtGlwf11hsMnh6OuUsjEbigzwA5y544kf+ > L/bPN1Bc2LwfoMffjjZceORTRK7/j1JrkkMNRYe1g+RjT6Vxio0kal83m6P61X7N > 4SwGzZCwHNwbK0I3O03Y7SsBd8uvtX905IyTKr1Vqh71LKVg3y3Xm0wrAeCWq6q5 > WmiUSOAyHPDuiC7YuYRCEqva0zTi5vBrZ4sDQT0uQ/p4JRLG6orIZWeDYqD+n4jE > OsFGnAGU7MGKoePElrxWecalxxrQg3Bd1rhp3+BbjKuSb+c43RjN6NflaExTER8S > kV8iXAheHhm/IE8JXjwuNHnWHx6PDe4tVyURVaaW8GSgkCXbqyCAwFV1CKxlTlWn > Vw6zW2S1K67Ffd7nsO4Z > =K5zX > -----END PGP SIGNATURE----- > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > >