Networking Forums

Networking Forums > Computer Networking > Linux Networking > Help - How to auto start a command

Reply
Thread Tools Display Modes

Help - How to auto start a command

 
 
Lamar Thomas
Guest
Posts: n/a

 
      07-16-2004, 07:50 PM
I am running RH 9.0 and I have the following commands that I have to run
EVERY time I restart my system. The commands start a chat server that is
running on my system.



Can someone tell me what I need to do to get these commands to run
automaticly in run level 3 and 5 each time I restart the system? I am using
bash and ssh to do this remotely.



Thanks for any and all help.



cd /usr/local/jabber/jabber-1.4.2

../jabberd/jabberd -D &

../jabberd/jabberd -c muc.xml -D &


Lamar


 
Reply With Quote
 
 
 
 
Hobart
Guest
Posts: n/a

 
      07-16-2004, 07:56 PM
Lamar Thomas wrote:

> I am running RH 9.0 and I have the following commands that I have to run
> EVERY time I restart my system. The commands start a chat server that is
> running on my system.
>
>
>
> Can someone tell me what I need to do to get these commands to run
> automaticly in run level 3 and 5 each time I restart the system? I am using
> bash and ssh to do this remotely.
>
>
>
> Thanks for any and all help.
>
>
>
> cd /usr/local/jabber/jabber-1.4.2
>
> ./jabberd/jabberd -D &
>
> ./jabberd/jabberd -c muc.xml -D &
>
>
> Lamar
>
>

http://www.linux.com/article.pl?sid=04/06/23/1734235
read this article, it tells how linux boots, and which files run various
commands in the various run levels.

Hope it helps.
 
Reply With Quote
 
Randy Sparks
Guest
Posts: n/a

 
      07-16-2004, 07:59 PM
Lamar Thomas wrote:

> I am running RH 9.0 and I have the following commands that I have to run
> EVERY time I restart my system. The commands start a chat server that is
> running on my system.
>
> Can someone tell me what I need to do to get these commands to run
> automaticly in run level 3 and 5 each time I restart the system? I am
> using bash and ssh to do this remotely.


Head into /etc/init.d and edit the S99local script so that the commands are
in there at the bottom.



>
>
>
> Thanks for any and all help.
>
>
>
> cd /usr/local/jabber/jabber-1.4.2
>
> ./jabberd/jabberd -D &
>
> ./jabberd/jabberd -c muc.xml -D &
>
>
> Lamar


 
Reply With Quote
 
Grant Edwards
Guest
Posts: n/a

 
      07-16-2004, 08:01 PM
On 2004-07-16, Lamar Thomas <(E-Mail Removed)> wrote:

> I am running RH 9.0 and I have the following commands that I
> have to run EVERY time I restart my system. The commands
> start a chat server that is running on my system.
>
> Can someone tell me what I need to do to get these commands to
> run automaticly in run level 3 and 5 each time I restart the
> system? I am using bash and ssh to do this remotely.


Create a shell script that starts/stops the service and place
it in /etc/rc.d/init.d

Then create symlinks links pointing to your script from
/etc/rc.d/rc3.d and /etc/rc.d/rc5.d that start with "S" to
start it, and symlinks starting with "K" in the other rcN.d
directories.

Take a look at these files for examples:

-rwxr--r-- 1 root root 3051 Feb 3 14:54 /etc/rc.d/init.d/sshd
lrwxrwxrwx 1 root root 14 May 1 17:15 /etc/rc.d/rc0.d/K25sshd -> ../init.d/sshd
lrwxrwxrwx 1 root root 14 May 1 17:15 /etc/rc.d/rc1.d/K25sshd -> ../init.d/sshd
lrwxrwxrwx 1 root root 14 May 1 17:15 /etc/rc.d/rc2.d/S55sshd -> ../init.d/sshd
lrwxrwxrwx 1 root root 14 May 1 17:15 /etc/rc.d/rc3.d/S55sshd -> ../init.d/sshd
lrwxrwxrwx 1 root root 14 May 1 17:15 /etc/rc.d/rc4.d/S55sshd -> ../init.d/sshd
lrwxrwxrwx 1 root root 14 May 1 17:15 /etc/rc.d/rc5.d/S55sshd -> ../init.d/sshd
lrwxrwxrwx 1 root root 14 May 1 17:15 /etc/rc.d/rc6.d/K25sshd -> ../init.d/sshd

[adjust paths as needed -- these were on a Mandrake 10 system,
but yours should be similar]

--
Grant Edwards grante Yow! QUIET!! I'm being
at CREATIVE!! Is it GREAT
visi.com yet? It's s'posed to SMOKEY
THE BEAR...
 
Reply With Quote
 
Bit Twister
Guest
Posts: n/a

 
      07-16-2004, 08:10 PM
On Fri, 16 Jul 2004 12:50:05 -0700, Lamar Thomas wrote:
> I am running RH 9.0 and I have the following commands that I have to run
> EVERY time I restart my system. The commands start a chat server that is
> running on my system.
>
>
>
> Can someone tell me what I need to do to get these commands to run
> automaticly in run level 3 and 5 each time I restart the system? I am using
> bash and ssh to do this remotely.


man chkconfig
man pkill

save following script to jabberd and follow install procedure.
This is untested off top of my head code.
---------8<----cut below here----------8<--------------8<--------------8<---
#! /bin/bash
#
# jabberd - start jabberd chat server
#
# chkconfig: 345 10 90
# description: start jabberd chat server
#
#* install procedure:
#* cp jabberd /etc/rc.d/init.d
#* chmod +x /etc/rc.d/init.d/jabberd
#* chkconfig --add jabberd
#* chkconfig jabberd on
#
#************************************************* **************************

case $1 in
start) cd /usr/local/jabber/jabber-1.4.2
./jabberd/jabberd -D &
./jabberd/jabberd -c muc.xml -D &
;;

stop) pkill jabberd
;;
esac

exit 0

#******************** end jabberd ************************************
 
Reply With Quote
 
Scott Lurndal
Guest
Posts: n/a

 
      07-16-2004, 09:51 PM
"Lamar Thomas" <(E-Mail Removed)> writes:
>I am running RH 9.0 and I have the following commands that I have to run
>EVERY time I restart my system. The commands start a chat server that is
>running on my system.
>
>
>
>Can someone tell me what I need to do to get these commands to run
>automaticly in run level 3 and 5 each time I restart the system? I am using
>bash and ssh to do this remotely.


create this file: /etc/rc.d/init.d/jabber
(see below for contents)
then
# chkconfig jabber on
# service jabber start

----
#!/bin/ksh
#
# Start jabber
#
# chkconfig: 2345 91 09
#

.. /etc/init.d/functions

.. /etc/sysconfig/network

[ ${NETWORKING} = "no" ] && exit 1

[ -f /usr/local/jabber/jabber-1.4.2/jabberd/jabberd ] || exit 1

jabber=/usr/local/jabber/jabber-1.4.2/jabberd/jabberd
prog=jabber
RETVAL=0

start () {
# Start daemons.

echo -n $"Starting $prog: "

daemon ${jabber} -D
daemon ${jabber} -c muc.xml -D

RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/jabber
return $RETVAL
}
stop () {
# Stop daemons.
echo -n $"Shutting down $prog: "
killproc jabber
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/jabber
return $RETVAL
}
restart() {
stop
start
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status jabber
;;
restart|reload)
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload}"
exit 1
esac


exit 0

 
Reply With Quote
 
Lamar Thomas
Guest
Posts: n/a

 
      07-16-2004, 10:41 PM
Will this work with the "BASH" shell? I saw that you used "#!/bin/ksh".


Lamar


"Scott Lurndal" <(E-Mail Removed)> wrote in message
news:u5YJc.92986$(E-Mail Removed). com...
> "Lamar Thomas" <(E-Mail Removed)> writes:
> >I am running RH 9.0 and I have the following commands that I have to run
> >EVERY time I restart my system. The commands start a chat server that is
> >running on my system.
> >
> >
> >
> >Can someone tell me what I need to do to get these commands to run
> >automaticly in run level 3 and 5 each time I restart the system? I am

using
> >bash and ssh to do this remotely.

>
> create this file: /etc/rc.d/init.d/jabber
> (see below for contents)
> then
> # chkconfig jabber on
> # service jabber start
>
> ----
> #!/bin/ksh
> #
> # Start jabber
> #
> # chkconfig: 2345 91 09
> #
>
> . /etc/init.d/functions
>
> . /etc/sysconfig/network
>
> [ ${NETWORKING} = "no" ] && exit 1
>
> [ -f /usr/local/jabber/jabber-1.4.2/jabberd/jabberd ] || exit 1
>
> jabber=/usr/local/jabber/jabber-1.4.2/jabberd/jabberd
> prog=jabber
> RETVAL=0
>
> start () {
> # Start daemons.
>
> echo -n $"Starting $prog: "
>
> daemon ${jabber} -D
> daemon ${jabber} -c muc.xml -D
>
> RETVAL=$?
> echo
> [ $RETVAL -eq 0 ] && touch /var/lock/subsys/jabber
> return $RETVAL
> }
> stop () {
> # Stop daemons.
> echo -n $"Shutting down $prog: "
> killproc jabber
> RETVAL=$?
> echo
> [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/jabber
> return $RETVAL
> }
> restart() {
> stop
> start
> }
>
> # See how we were called.
> case "$1" in
> start)
> start
> ;;
> stop)
> stop
> ;;
> status)
> status jabber
> ;;
> restart|reload)
> restart
> ;;
> *)
> echo $"Usage: $0 {start|stop|status|restart|reload}"
> exit 1
> esac
>
>
> exit 0
>



 
Reply With Quote
 
Lamar Thomas
Guest
Posts: n/a

 
      07-16-2004, 10:41 PM
Thanks Bit, that worked!


Lamar



"Bit Twister" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Fri, 16 Jul 2004 12:50:05 -0700, Lamar Thomas wrote:
> > I am running RH 9.0 and I have the following commands that I have to run
> > EVERY time I restart my system. The commands start a chat server that

is
> > running on my system.
> >
> >
> >
> > Can someone tell me what I need to do to get these commands to run
> > automaticly in run level 3 and 5 each time I restart the system? I am

using
> > bash and ssh to do this remotely.

>
> man chkconfig
> man pkill
>
> save following script to jabberd and follow install procedure.
> This is untested off top of my head code.
> ---------8<----cut below

here----------8<--------------8<--------------8<---
> #! /bin/bash
> #
> # jabberd - start jabberd chat server
> #
> # chkconfig: 345 10 90
> # description: start jabberd chat server
> #
> #* install procedure:
> #* cp jabberd /etc/rc.d/init.d
> #* chmod +x /etc/rc.d/init.d/jabberd
> #* chkconfig --add jabberd
> #* chkconfig jabberd on
> #
>

#************************************************* **************************
>
> case $1 in
> start) cd /usr/local/jabber/jabber-1.4.2
> ./jabberd/jabberd -D &
> ./jabberd/jabberd -c muc.xml -D &
> ;;
>
> stop) pkill jabberd
> ;;
> esac
>
> exit 0
>
> #******************** end jabberd ************************************



 
Reply With Quote
 
Scott Lurndal
Guest
Posts: n/a

 
      07-17-2004, 12:26 AM
"Lamar Thomas" <(E-Mail Removed)> writes:
>Will this work with the "BASH" shell? I saw that you used "#!/bin/ksh".


yes. I personally prefer the korn shell (pdksh or the real thing), but
the script I attached uses only Posix semantics so should work with
either shell.

scott

>
>
>Lamar
>
>
>"Scott Lurndal" <(E-Mail Removed)> wrote in message
>news:u5YJc.92986$(E-Mail Removed) .com...
>> "Lamar Thomas" <(E-Mail Removed)> writes:
>> >I am running RH 9.0 and I have the following commands that I have to run
>> >EVERY time I restart my system. The commands start a chat server that is
>> >running on my system.
>> >
>> >
>> >
>> >Can someone tell me what I need to do to get these commands to run
>> >automaticly in run level 3 and 5 each time I restart the system? I am

>using
>> >bash and ssh to do this remotely.

>>
>> create this file: /etc/rc.d/init.d/jabber
>> (see below for contents)
>> then
>> # chkconfig jabber on
>> # service jabber start
>>
>> ----
>> #!/bin/ksh
>> #
>> # Start jabber
>> #
>> # chkconfig: 2345 91 09
>> #
>>
>> . /etc/init.d/functions
>>
>> . /etc/sysconfig/network
>>
>> [ ${NETWORKING} = "no" ] && exit 1
>>
>> [ -f /usr/local/jabber/jabber-1.4.2/jabberd/jabberd ] || exit 1
>>
>> jabber=/usr/local/jabber/jabber-1.4.2/jabberd/jabberd
>> prog=jabber
>> RETVAL=0
>>
>> start () {
>> # Start daemons.
>>
>> echo -n $"Starting $prog: "
>>
>> daemon ${jabber} -D
>> daemon ${jabber} -c muc.xml -D
>>
>> RETVAL=$?
>> echo
>> [ $RETVAL -eq 0 ] && touch /var/lock/subsys/jabber
>> return $RETVAL
>> }
>> stop () {
>> # Stop daemons.
>> echo -n $"Shutting down $prog: "
>> killproc jabber
>> RETVAL=$?
>> echo
>> [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/jabber
>> return $RETVAL
>> }
>> restart() {
>> stop
>> start
>> }
>>
>> # See how we were called.
>> case "$1" in
>> start)
>> start
>> ;;
>> stop)
>> stop
>> ;;
>> status)
>> status jabber
>> ;;
>> restart|reload)
>> restart
>> ;;
>> *)
>> echo $"Usage: $0 {start|stop|status|restart|reload}"
>> exit 1
>> esac
>>
>>
>> exit 0
>>

>
>

 
Reply With Quote
 
Lamar Thomas
Guest
Posts: n/a

 
      07-17-2004, 11:33 AM
Thanks Scott!


Lamar


"Scott Lurndal" <(E-Mail Removed)> wrote in message
news:Vm_Jc.21148$(E-Mail Removed). com...
> "Lamar Thomas" <(E-Mail Removed)> writes:
> >Will this work with the "BASH" shell? I saw that you used "#!/bin/ksh".

>
> yes. I personally prefer the korn shell (pdksh or the real thing), but
> the script I attached uses only Posix semantics so should work with
> either shell.
>
> scott
>
> >
> >
> >Lamar
> >
> >
> >"Scott Lurndal" <(E-Mail Removed)> wrote in message
> >news:u5YJc.92986$(E-Mail Removed) .com...
> >> "Lamar Thomas" <(E-Mail Removed)> writes:
> >> >I am running RH 9.0 and I have the following commands that I have to

run
> >> >EVERY time I restart my system. The commands start a chat server that

is
> >> >running on my system.
> >> >
> >> >
> >> >
> >> >Can someone tell me what I need to do to get these commands to run
> >> >automaticly in run level 3 and 5 each time I restart the system? I am

> >using
> >> >bash and ssh to do this remotely.
> >>
> >> create this file: /etc/rc.d/init.d/jabber
> >> (see below for contents)
> >> then
> >> # chkconfig jabber on
> >> # service jabber start
> >>
> >> ----
> >> #!/bin/ksh
> >> #
> >> # Start jabber
> >> #
> >> # chkconfig: 2345 91 09
> >> #
> >>
> >> . /etc/init.d/functions
> >>
> >> . /etc/sysconfig/network
> >>
> >> [ ${NETWORKING} = "no" ] && exit 1
> >>
> >> [ -f /usr/local/jabber/jabber-1.4.2/jabberd/jabberd ] || exit 1
> >>
> >> jabber=/usr/local/jabber/jabber-1.4.2/jabberd/jabberd
> >> prog=jabber
> >> RETVAL=0
> >>
> >> start () {
> >> # Start daemons.
> >>
> >> echo -n $"Starting $prog: "
> >>
> >> daemon ${jabber} -D
> >> daemon ${jabber} -c muc.xml -D
> >>
> >> RETVAL=$?
> >> echo
> >> [ $RETVAL -eq 0 ] && touch /var/lock/subsys/jabber
> >> return $RETVAL
> >> }
> >> stop () {
> >> # Stop daemons.
> >> echo -n $"Shutting down $prog: "
> >> killproc jabber
> >> RETVAL=$?
> >> echo
> >> [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/jabber
> >> return $RETVAL
> >> }
> >> restart() {
> >> stop
> >> start
> >> }
> >>
> >> # See how we were called.
> >> case "$1" in
> >> start)
> >> start
> >> ;;
> >> stop)
> >> stop
> >> ;;
> >> status)
> >> status jabber
> >> ;;
> >> restart|reload)
> >> restart
> >> ;;
> >> *)
> >> echo $"Usage: $0 {start|stop|status|restart|reload}"
> >> exit 1
> >> esac
> >>
> >>
> >> exit 0
> >>

> >
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Shipping Auto Shipping Scheduling:car moving auto transport linkswanted Wireless Internet 0 02-16-2008 01:40 AM
Auto start TonyTaylor Wireless Networks 2 04-26-2007 05:55 PM
WZC service no auto start John I Wireless Networks 1 06-27-2005 05:34 PM
Start VPN from the command line? Croco Stimpy Windows Networking 1 04-26-2004 06:31 PM
Net Start / Net Use Command =?Utf-8?B?Sm9obiBNY0xhZ2Fu?= Windows Networking 0 04-16-2004 08:21 PM



1 2 3 4 5 6 7 8 9 10 11