Re: How to create startup script which start and stop certain services automatically.
Pravin Uttam Kharat <[email protected]> Wed, 30 Jun 2010 21:40:45 +0530
| Newsgroups | gmane.linux.redhat.rhn.user |
|---|---|
| Message-ID | <[email protected]> |
--===============8697275568565753831== Content-Type: multipart/alternative; boundary=0016363b9048a7bdbb048a419877 --0016363b9048a7bdbb048a419877 Content-Type: text/plain; charset=ISO-8859-1 I put script file path in inittab file to start script...........and it works.... On Wed, Jun 30, 2010 at 8:12 PM, Christopher L. Barnard <[email protected]>wrote: > Put it in /etc/rc2.d. > > Or put "startDMS" in /etc/init.d and then create the symlink > in /etc/rc2.d that points S97startDMS -> ../init.d/startDMS. > > -- > Christopher L. Barnard > --------------------------------------------------------------------- > Comment your code as though the maintainer will be a homicidal maniac > who knows where you live. > > > On Wed, 2010-06-30 at 18:54 +0530, Pravin Uttam Kharat wrote: > > HI, > > > > > > > > I couldn't understand in this procedure. > > I have a created a script in vi S97startDMS. This contains following > > line > > /opt/DMS/ctlscript.sh start > > Now where to put this script to run at start up. > > > > > > Thanks > > > > > > > > > > On Tue, Jun 29, 2010 at 8:48 PM, Bill Watson <[email protected]> > > wrote: > > On Tue, 2010-06-29 at 10:44 +1000, Cameron Simpson wrote: > > > On 28Jun2010 10:16, Christopher L. Barnard > > <[email protected]> wrote: > > > | On Mon, 2010-06-28 at 15:08 +0530, Pravin Uttam Kharat > > wrote: > > > | > I have RHEL 5 I installed Bitnami Joomla on it.I want to > > configure a > > > | > startup script which run that script when RHEL 5 Machine > > start and > > > | > automatically shut down machine on mentioned time. > > Please suggest any > > > | > tool for this...... > > > | > > > | [ Excellent description of the SnnFOO script scheme... ] > > > | You can put it all in one script, and that is much easier > > for other > > > | individuals to understand what you are doing. For > > 'start', the script > > > | is called with the command line parameter of "start". > > Likewise 'stop' > > > | is called with the command line parameter of "stop". So > > just switch on > > > | the command line parameter and you can put the script > > in /etc/init.d > > > | with a symlink to /etc/rc2.d/S****** and > > to /etc/rc0.d/K****** > > > > > > And for your second requirement, have the "start" script use > > the "at" > > > command to schedule a run of the "stop" script at a suitable > > time. > > > > Only if you want the script to be alive for a finite time. If > > the need > > is for the app to start gracefully on system startup and stop > > gracefully > > on system shutdown, then 'at' should definitely not be used. > > If it > > should run for oh, say, the first 17 hours after powerup, then > > yes the > > at command should be used. > > > > -- > > Christopher L. Barnard > > > --------------------------------------------------------------------- > > Comment your code as though the maintainer will be a homicidal > > maniac > > who knows where you live. > > > > > > ************** I had to leave this tag line - it's too good! > > The source stated to start with the machine start and end at > > "on mentioned > > time". If the mentioned time is other than the machine shut > > down time, then > > a crontab entry calling the "K50scriptname stop" would do > > well. > > > > Also it seems that the "RedHat" way to do rc#.d these days is > > to place the > > file without Snn or Knn into /etc/init.d with the following > > lines at the > > top: > > #!/bin/bash > > # > > # chkconfig: - 91 35 > > # description: stuff this script does comment here > > > > The 91 is the starting sequence within rc2.d (S91) and the 35 > > is the > > stopping sequence in rc0.d (K35) and the 91 and 35 are > > adjustable to your > > needs as long as they are 2 digits each. > > > > Then > > chkconfig --add scriptname > > chkconfig scriptname on > > > > ^^^^ The above is from memory and to be taken with a grain of > > salt, lemon, > > and tequila. Hope this helps. > > Bill Watson > > [email protected] > > > > > > > > _______________________________________________ > > rhn-users mailing list > > [email protected] > > https://www.redhat.com/mailman/listinfo/rhn-users > > > > > > _______________________________________________ > > rhn-users mailing list > > [email protected] > > https://www.redhat.com/mailman/listinfo/rhn-users > > _______________________________________________ > rhn-users mailing list > [email protected] > https://www.redhat.com/mailman/listinfo/rhn-users > --0016363b9048a7bdbb048a419877 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I put script file path in inittab file to start script...........and it wor= ks.... <br><br><div class=3D"gmail_quote">On Wed, Jun 30, 2010 at 8:12 PM, = Christopher L. Barnard <span dir=3D"ltr"><<a href=3D"mailto:cbarnard@rus= h.edu">[email protected]</a>></span> wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin: 0pt 0pt 0pt 0.8ex; borde= r-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Put it in /etc/rc= 2.d.<br> <br> Or put "startDMS" in /etc/init.d and then create the symlink<br> in /etc/rc2.d that points S97startDMS -> ../init.d/startDMS.<br> <font color=3D"#888888"><br> --<br> </font><div class=3D"im">Christopher L. Barnard<br> ---------------------------------------------------------------------<br> Comment your code as though the maintainer will be a homicidal maniac<br> who knows where you live.<br> <br> <br> </div><div><div></div><div class=3D"h5">On Wed, 2010-06-30 at 18:54 +0530, = Pravin Uttam Kharat wrote:<br> > HI,<br> ><br> ><br> ><br> > I couldn't understand in this procedure.<br> > I have a created a script in vi S97startDMS. This contains following<b= r> > line<br> > /opt/DMS/ctlscript.sh start<br> > Now =A0where to put this script to run at start up.<br> ><br> ><br> > Thanks<br> ><br> ><br> ><br> ><br> > On Tue, Jun 29, 2010 at 8:48 PM, Bill Watson <<a href=3D"mailto:bil= [email protected]">[email protected]</a>><br> > wrote:<br> > =A0 =A0 =A0 =A0 On Tue, 2010-06-29 at 10:44 +1000, Cameron Simpson wro= te:<br> > =A0 =A0 =A0 =A0 > On 28Jun2010 10:16, Christopher L. Barnard<br> > =A0 =A0 =A0 =A0 <<a href=3D"mailto:[email protected]">cbarnard@rush= .edu</a>> wrote:<br> > =A0 =A0 =A0 =A0 > | On Mon, 2010-06-28 at 15:08 +0530, Pravin Uttam= Kharat<br> > =A0 =A0 =A0 =A0 wrote:<br> > =A0 =A0 =A0 =A0 > | > I have RHEL 5 I installed Bitnami Joomla o= n it.I want to<br> > =A0 =A0 =A0 =A0 configure a<br> > =A0 =A0 =A0 =A0 > | > startup script which run that script when = RHEL 5 Machine<br> > =A0 =A0 =A0 =A0 start and<br> > =A0 =A0 =A0 =A0 > | > automatically shut down machine on mention= ed time.<br> > =A0 =A0 =A0 =A0 Please suggest any<br> > =A0 =A0 =A0 =A0 > | > tool for this......<br> > =A0 =A0 =A0 =A0 > |<br> > =A0 =A0 =A0 =A0 > | [ Excellent description of the SnnFOO script sc= heme... ]<br> > =A0 =A0 =A0 =A0 > | You can put it all in one script, and that is m= uch easier<br> > =A0 =A0 =A0 =A0 for other<br> > =A0 =A0 =A0 =A0 > | individuals to understand what you are doing. = =A0For<br> > =A0 =A0 =A0 =A0 'start', the script<br> > =A0 =A0 =A0 =A0 > | is called with the command line parameter of &q= uot;start".<br> > =A0 =A0 =A0 =A0 Likewise 'stop'<br> > =A0 =A0 =A0 =A0 > | is called with the command line parameter of &q= uot;stop". =A0So<br> > =A0 =A0 =A0 =A0 just switch on<br> > =A0 =A0 =A0 =A0 > | the command line parameter and you can put the = script<br> > =A0 =A0 =A0 =A0 in /etc/init.d<br> > =A0 =A0 =A0 =A0 > | with a symlink to /etc/rc2.d/S****** and<br> > =A0 =A0 =A0 =A0 to /etc/rc0.d/K******<br> > =A0 =A0 =A0 =A0 ><br> > =A0 =A0 =A0 =A0 > And for your second requirement, have the "s= tart" script use<br> > =A0 =A0 =A0 =A0 the "at"<br> > =A0 =A0 =A0 =A0 > command to schedule a run of the "stop"= script at a suitable<br> > =A0 =A0 =A0 =A0 time.<br> ><br> > =A0 =A0 =A0 =A0 Only if you want the script to be alive for a finite t= ime. =A0If<br> > =A0 =A0 =A0 =A0 the need<br> > =A0 =A0 =A0 =A0 is for the app to start gracefully on system startup a= nd stop<br> > =A0 =A0 =A0 =A0 gracefully<br> > =A0 =A0 =A0 =A0 on system shutdown, then 'at' should definitel= y not be used.<br> > =A0 =A0 =A0 =A0 =A0If it<br> > =A0 =A0 =A0 =A0 should run for oh, say, the first 17 hours after power= up, then<br> > =A0 =A0 =A0 =A0 yes the<br> > =A0 =A0 =A0 =A0 at command should be used.<br> ><br> > =A0 =A0 =A0 =A0 --<br> > =A0 =A0 =A0 =A0 Christopher L. Barnard<br> > =A0 =A0 =A0 =A0 ------------------------------------------------------= ---------------<br> > =A0 =A0 =A0 =A0 Comment your code as though the maintainer will be a h= omicidal<br> > =A0 =A0 =A0 =A0 maniac<br> > =A0 =A0 =A0 =A0 who knows where you live.<br> ><br> ><br> > =A0 =A0 =A0 =A0 ************** I had to leave this tag line - it's= too good!<br> > =A0 =A0 =A0 =A0 The source stated to start with the machine start and = end at<br> > =A0 =A0 =A0 =A0 "on mentioned<br> > =A0 =A0 =A0 =A0 time". If the mentioned time is other than the ma= chine shut<br> > =A0 =A0 =A0 =A0 down time, then<br> > =A0 =A0 =A0 =A0 a crontab entry calling the "K50scriptname stop&q= uot; would do<br> > =A0 =A0 =A0 =A0 well.<br> ><br> > =A0 =A0 =A0 =A0 Also it seems that the "RedHat" way to do rc= #.d these days is<br> > =A0 =A0 =A0 =A0 to place the<br> > =A0 =A0 =A0 =A0 file without Snn or Knn into /etc/init.d with the foll= owing<br> > =A0 =A0 =A0 =A0 lines at the<br> > =A0 =A0 =A0 =A0 top:<br> > =A0 =A0 =A0 =A0 #!/bin/bash<br> > =A0 =A0 =A0 =A0 #<br> > =A0 =A0 =A0 =A0 # chkconfig: - 91 35<br> > =A0 =A0 =A0 =A0 # description: stuff this script does comment here<br> ><br> > =A0 =A0 =A0 =A0 The 91 is the starting sequence within rc2.d (S91) and= the 35<br> > =A0 =A0 =A0 =A0 is the<br> > =A0 =A0 =A0 =A0 stopping sequence in rc0.d (K35) and the 91 and 35 are= <br> > =A0 =A0 =A0 =A0 adjustable to your<br> > =A0 =A0 =A0 =A0 needs as long as they are 2 digits each.<br> ><br> > =A0 =A0 =A0 =A0 Then<br> > =A0 =A0 =A0 =A0 chkconfig --add scriptname<br> > =A0 =A0 =A0 =A0 chkconfig scriptname on<br> ><br> > =A0 =A0 =A0 =A0 ^^^^ The above is from memory and to be taken with a g= rain of<br> > =A0 =A0 =A0 =A0 salt, lemon,<br> > =A0 =A0 =A0 =A0 and tequila. Hope this helps.<br> > =A0 =A0 =A0 =A0 Bill Watson<br> > =A0 =A0 =A0 =A0 <a href=3D"mailto:[email protected]">bill@magicdigi= ts.com</a><br> ><br> ><br> ><br> > =A0 =A0 =A0 =A0 _______________________________________________<br> > =A0 =A0 =A0 =A0 rhn-users mailing list<br> > =A0 =A0 =A0 =A0 <a href=3D"mailto:[email protected]">rhn-users@redh= at.com</a><br> > =A0 =A0 =A0 =A0 <a href=3D"https://www.redhat.com/mailman/listinfo/rhn= -users" target=3D"_blank">https://www.redhat.com/mailman/listinfo/rhn-users= </a><br> ><br> ><br> > _______________________________________________<br> > rhn-users mailing list<br> > <a href=3D"mailto:[email protected]">[email protected]</a><br> > <a href=3D"https://www.redhat.com/mailman/listinfo/rhn-users" target= =3D"_blank">https://www.redhat.com/mailman/listinfo/rhn-users</a><br> <br> _______________________________________________<br> rhn-users mailing list<br> <a href=3D"mailto:[email protected]">[email protected]</a><br> <a href=3D"https://www.redhat.com/mailman/listinfo/rhn-users" target=3D"_bl= ank">https://www.redhat.com/mailman/listinfo/rhn-users</a><br> </div></div></blockquote></div><br> --0016363b9048a7bdbb048a419877-- --===============8697275568565753831== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ rhn-users mailing list [email protected] https://www.redhat.com/mailman/listinfo/rhn-users --===============8697275568565753831==--