Re: best way to start and shutdown programs in CentOS?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On 11/21/10 4:19 PM, Kill Script wrote:
> I have a Java program that I want to start up with every boot, but I'm 
> unsure how to do it.
>
> There are two bootup scripts that start manually (script1.sh and 
> script2.sh), and when the server gets shutdown, we have another script 
> that we run (shutdownscript.sh) so that the DB does not get corrupted.
>

centos uses sysVinit.

you would create a script in /etc/rc.d/init.d/   called yourjavathing, 
which takes the parameter {start|stop} and optionally 
{reload|restart|status} ...  this script would include the header lines 
for chkconfig.   its run by init as the root user (but without any user 
login profiles).   If you want your javathing to run as a different 
user, you should invoke your script1.sh and script2.sh via su someuser 
-c "/path/to/script1.sh" ...

once this script exists, and you test it by invoking it as 
"/etc/rc.d/init.d/yourjavathing start" (and "... stop", etc), then

      chkconfig --on yourjavathing

will configure the OS to run it automatically at the runlevels that your 
chkconfig header lines specify.  and,

     service yourjavathing start

(or stop, etc) will manually start and stop the service.
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos


[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux