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">&lt;<a href=3D"mailto:cbarnard@rus=
h.edu">[email protected]</a>&gt;</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 &quot;startDMS&quot; in /etc/init.d and then create the symlink<br>
in /etc/rc2.d that points S97startDMS -&gt; ../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>
&gt; HI,<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; I couldn&#39;t understand in this procedure.<br>
&gt; I have a created a script in vi S97startDMS. This contains following<b=
r>
&gt; line<br>
&gt; /opt/DMS/ctlscript.sh start<br>
&gt; Now =A0where to put this script to run at start up.<br>
&gt;<br>
&gt;<br>
&gt; Thanks<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Tue, Jun 29, 2010 at 8:48 PM, Bill Watson &lt;<a href=3D"mailto:bil=
[email protected]">[email protected]</a>&gt;<br>
&gt; wrote:<br>
&gt; =A0 =A0 =A0 =A0 On Tue, 2010-06-29 at 10:44 +1000, Cameron Simpson wro=
te:<br>
&gt; =A0 =A0 =A0 =A0 &gt; On 28Jun2010 10:16, Christopher L. Barnard<br>
&gt; =A0 =A0 =A0 =A0 &lt;<a href=3D"mailto:[email protected]">cbarnard@rush=
.edu</a>&gt; wrote:<br>
&gt; =A0 =A0 =A0 =A0 &gt; | On Mon, 2010-06-28 at 15:08 +0530, Pravin Uttam=
 Kharat<br>
&gt; =A0 =A0 =A0 =A0 wrote:<br>
&gt; =A0 =A0 =A0 =A0 &gt; | &gt; I have RHEL 5 I installed Bitnami Joomla o=
n it.I want to<br>
&gt; =A0 =A0 =A0 =A0 configure a<br>
&gt; =A0 =A0 =A0 =A0 &gt; | &gt; startup script which run that script when =
RHEL 5 Machine<br>
&gt; =A0 =A0 =A0 =A0 start and<br>
&gt; =A0 =A0 =A0 =A0 &gt; | &gt; automatically shut down machine on mention=
ed time.<br>
&gt; =A0 =A0 =A0 =A0 Please suggest any<br>
&gt; =A0 =A0 =A0 =A0 &gt; | &gt; tool for this......<br>
&gt; =A0 =A0 =A0 =A0 &gt; |<br>
&gt; =A0 =A0 =A0 =A0 &gt; | [ Excellent description of the SnnFOO script sc=
heme... ]<br>
&gt; =A0 =A0 =A0 =A0 &gt; | You can put it all in one script, and that is m=
uch easier<br>
&gt; =A0 =A0 =A0 =A0 for other<br>
&gt; =A0 =A0 =A0 =A0 &gt; | individuals to understand what you are doing. =
=A0For<br>
&gt; =A0 =A0 =A0 =A0 &#39;start&#39;, the script<br>
&gt; =A0 =A0 =A0 =A0 &gt; | is called with the command line parameter of &q=
uot;start&quot;.<br>
&gt; =A0 =A0 =A0 =A0 Likewise &#39;stop&#39;<br>
&gt; =A0 =A0 =A0 =A0 &gt; | is called with the command line parameter of &q=
uot;stop&quot;. =A0So<br>
&gt; =A0 =A0 =A0 =A0 just switch on<br>
&gt; =A0 =A0 =A0 =A0 &gt; | the command line parameter and you can put the =
script<br>
&gt; =A0 =A0 =A0 =A0 in /etc/init.d<br>
&gt; =A0 =A0 =A0 =A0 &gt; | with a symlink to /etc/rc2.d/S****** and<br>
&gt; =A0 =A0 =A0 =A0 to /etc/rc0.d/K******<br>
&gt; =A0 =A0 =A0 =A0 &gt;<br>
&gt; =A0 =A0 =A0 =A0 &gt; And for your second requirement, have the &quot;s=
tart&quot; script use<br>
&gt; =A0 =A0 =A0 =A0 the &quot;at&quot;<br>
&gt; =A0 =A0 =A0 =A0 &gt; command to schedule a run of the &quot;stop&quot;=
 script at a suitable<br>
&gt; =A0 =A0 =A0 =A0 time.<br>
&gt;<br>
&gt; =A0 =A0 =A0 =A0 Only if you want the script to be alive for a finite t=
ime. =A0If<br>
&gt; =A0 =A0 =A0 =A0 the need<br>
&gt; =A0 =A0 =A0 =A0 is for the app to start gracefully on system startup a=
nd stop<br>
&gt; =A0 =A0 =A0 =A0 gracefully<br>
&gt; =A0 =A0 =A0 =A0 on system shutdown, then &#39;at&#39; should definitel=
y not be used.<br>
&gt; =A0 =A0 =A0 =A0 =A0If it<br>
&gt; =A0 =A0 =A0 =A0 should run for oh, say, the first 17 hours after power=
up, then<br>
&gt; =A0 =A0 =A0 =A0 yes the<br>
&gt; =A0 =A0 =A0 =A0 at command should be used.<br>
&gt;<br>
&gt; =A0 =A0 =A0 =A0 --<br>
&gt; =A0 =A0 =A0 =A0 Christopher L. Barnard<br>
&gt; =A0 =A0 =A0 =A0 ------------------------------------------------------=
---------------<br>
&gt; =A0 =A0 =A0 =A0 Comment your code as though the maintainer will be a h=
omicidal<br>
&gt; =A0 =A0 =A0 =A0 maniac<br>
&gt; =A0 =A0 =A0 =A0 who knows where you live.<br>
&gt;<br>
&gt;<br>
&gt; =A0 =A0 =A0 =A0 ************** I had to leave this tag line - it&#39;s=
 too good!<br>
&gt; =A0 =A0 =A0 =A0 The source stated to start with the machine start and =
end at<br>
&gt; =A0 =A0 =A0 =A0 &quot;on mentioned<br>
&gt; =A0 =A0 =A0 =A0 time&quot;. If the mentioned time is other than the ma=
chine shut<br>
&gt; =A0 =A0 =A0 =A0 down time, then<br>
&gt; =A0 =A0 =A0 =A0 a crontab entry calling the &quot;K50scriptname stop&q=
uot; would do<br>
&gt; =A0 =A0 =A0 =A0 well.<br>
&gt;<br>
&gt; =A0 =A0 =A0 =A0 Also it seems that the &quot;RedHat&quot; way to do rc=
#.d these days is<br>
&gt; =A0 =A0 =A0 =A0 to place the<br>
&gt; =A0 =A0 =A0 =A0 file without Snn or Knn into /etc/init.d with the foll=
owing<br>
&gt; =A0 =A0 =A0 =A0 lines at the<br>
&gt; =A0 =A0 =A0 =A0 top:<br>
&gt; =A0 =A0 =A0 =A0 #!/bin/bash<br>
&gt; =A0 =A0 =A0 =A0 #<br>
&gt; =A0 =A0 =A0 =A0 # chkconfig: - 91 35<br>
&gt; =A0 =A0 =A0 =A0 # description: stuff this script does comment here<br>
&gt;<br>
&gt; =A0 =A0 =A0 =A0 The 91 is the starting sequence within rc2.d (S91) and=
 the 35<br>
&gt; =A0 =A0 =A0 =A0 is the<br>
&gt; =A0 =A0 =A0 =A0 stopping sequence in rc0.d (K35) and the 91 and 35 are=
<br>
&gt; =A0 =A0 =A0 =A0 adjustable to your<br>
&gt; =A0 =A0 =A0 =A0 needs as long as they are 2 digits each.<br>
&gt;<br>
&gt; =A0 =A0 =A0 =A0 Then<br>
&gt; =A0 =A0 =A0 =A0 chkconfig --add scriptname<br>
&gt; =A0 =A0 =A0 =A0 chkconfig scriptname on<br>
&gt;<br>
&gt; =A0 =A0 =A0 =A0 ^^^^ The above is from memory and to be taken with a g=
rain of<br>
&gt; =A0 =A0 =A0 =A0 salt, lemon,<br>
&gt; =A0 =A0 =A0 =A0 and tequila. Hope this helps.<br>
&gt; =A0 =A0 =A0 =A0 Bill Watson<br>
&gt; =A0 =A0 =A0 =A0 <a href=3D"mailto:[email protected]">bill@magicdigi=
ts.com</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; =A0 =A0 =A0 =A0 _______________________________________________<br>
&gt; =A0 =A0 =A0 =A0 rhn-users mailing list<br>
&gt; =A0 =A0 =A0 =A0 <a href=3D"mailto:[email protected]">rhn-users@redh=
at.com</a><br>
&gt; =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>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; rhn-users mailing list<br>
&gt; <a href=3D"mailto:[email protected]">[email protected]</a><br>
&gt; <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==--