nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

start up and stop the running script

This is a discussion on start up and stop the running script within the Shell scripting forums, part of the Development/Scripting category; i create my script inside /etc/rc.d/rc3.d/filename i named my filename=S99zz this script that will continues running... i believed its not ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 07-20-2006, 04:01 PM
Junior Member
User
 
Join Date: Jul 2006
Posts: 11
Rep Power: 0
mala_un
Default start up and stop the running script

i create my script inside /etc/rc.d/rc3.d/filename
i named my filename=S99zz

this script that will continues running...
i believed its not ok to enter ctrl+c...
how is it?
do i have to enter some lines at rc6.d...(since rc6.d is responsible for shutting down)
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-20-2006, 07:24 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

You need to create SYS V style script in /etc/ini.d/ directory. Next softlink same from runlevel 2/3/6 i.e. /etc/rc3.d/ and /etc/rc6.d/ directory:

For example if script name is /etc/init.d/script
Code:
cd /etc/rc2.d
ln -s ../init.d/script S99script
cd /etc/rc6.d
ln -s ../init.d/script K99script
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #3 (permalink)  
Old 07-21-2006, 07:52 AM
Junior Member
User
 
Join Date: Jul 2006
Posts: 11
Rep Power: 0
mala_un
Default

from your replied post, i'm a bit confuse...
i already named my script S99zz

where should i put the code

cd /etc/rc3.d
ln -s /etc/init.d/S99zz S99??
cd /etc/rc6.d
ln -s /etc/init.d/S99zz K99??

sorry for being so miserable...
Reply With Quote
  #4 (permalink)  
Old 07-21-2006, 08:33 AM
Junior Member
User
 
Join Date: Jul 2006
Posts: 11
Rep Power: 0
mala_un
Default

i've tried...
correct me if i'm doing wrong...

i create a file in /etc/init.d
the filename is test

inside the test..i put
#!/bin/bash
cd /etc/rc3.d
ln -s /etc/init.d/test S99test
cd /etc/rc6.d
ln -s /etc/init.d/test K99test

i've looking what is happening to the system...
and discover that S99test is created inside /etc/rc3.d
also, K99test is created inside /etc/rc6.d

the thing is... where should i put my real script?
still in puzzled...

please help me...
Reply With Quote
  #5 (permalink)  
Old 07-21-2006, 03:05 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Quote:
where should i put the code
Err … you need to put actual script (test) in /etc/init.d/ And type the above commands at shell prompt (not in script). Script is use to start or stop some service.

Step # 1: Create a script called test
Code:
cd  /etc/init.d
Now write script
Code:
vi test
Step # 2: Create a startup soft link
Code:
cd /etc/rc2.d
ln -s ../init.d/test S99test
Step # 2: Create a shutdown soft link
[code]cd /etc/rc6.d
ln -s ../init.d/test K99test[code]

For example here is how my oracle startup script looks
http://bash.cyberciti.biz/script/ora...service.sh.php

Now I need to copy this script to /etc/init.d/ directory.

Next, softlink pracle using ln command
[code]cd /etc/rc2.d
ln -s ../init.d/oracle S99oracle[/code]
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #6 (permalink)  
Old 07-24-2006, 08:03 AM
Junior Member
User
 
Join Date: Jul 2006
Posts: 11
Rep Power: 0
mala_un
Default

thanks nixcraft...
u really help me alot...

my script appear before the OS (montaVista) is loading..
and my script, will copy some files in to another file and later will reboot...
this will run continuosly...
i cant hit ctrl+c to stop the script while it running my script..
is there any other way to stop them...

thanks in advance
Reply With Quote
  #7 (permalink)  
Old 07-25-2006, 01:39 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

You need to put some logic in script to stop. I hope you have written proper sys v style script with stop, start arguments? can you paste your script so that i can help you
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #8 (permalink)  
Old 07-25-2006, 05:20 PM
Junior Member
User
 
Join Date: Jul 2006
Posts: 11
Rep Power: 0
mala_un
Default

#!/bin/bash
echo "Start Processing" >> ~/mylog.txt
true=1
while [ $true ]
do
echo "$date $*" >> ~/mylog.txt
echo Counter >> ~/mylog1.txt
count=0
echo
exec 3<>mylog1.txt
while read line < &3
do {
echo "$line"
((count++));
}
done
exec 3>&-
echo "Counter=$count"
echo
mv C:\BIOS\P12N0027.ROM C:\BIOS\DUMMY.ROM
mv C:\BIOS\P13N0028.ROM C:\BIOS\P12N0027.ROM
mv C:\BIOS\DUMMY.ROM C:\BIOS\P13N0028.ROM
sleep 1
shutdown -r now
done

day by day... my script is getting better...
i'll notify you if i made changes
Reply With Quote
  #9 (permalink)  
Old 07-26-2006, 12:14 AM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

ok, note that above is not sys v style script it a just script as per your need. let me know if you need further help
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #10 (permalink)  
Old 07-26-2006, 08:10 AM
Junior Member
User
 
Join Date: Jul 2006
Posts: 11
Rep Power: 0
mala_un
Default

nixcraft...
what is the meaning of SYS V style?

i did put a timer at my script and did run well...
but then i concern about .cfg file...

i did browse around and did open my .cfg file inside my Fedora core... but i cant see the way..

can you give me example of simple .cfg file..

my sv said that if i wanted user to enter the data and saved as the varible for next execution, i need .cfg file..

please help me
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
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 On

Similar Threads

Thread Thread Starter Forum Replies Last Post
How to stop hibernate mode on Laptop mendoza Getting started tutorials 3 09-08-2007 06:01 PM
start and stop service in crontab. gthian Shell scripting 7 05-31-2007 12:04 PM
ubuntu linux start, stop, restart networking toor Linux software 3 07-17-2006 12:32 PM
required help for running a shell script from browser vaishalichitale Shell scripting 1 06-27-2006 05:53 PM
running .sh script linux jerry Shell scripting 1 06-17-2006 02:45 PM


All times are GMT +5.5. The time now is 07:19 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36