nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Script file to be run when linux boot

This is a discussion on Script file to be run when linux boot within the Shell scripting forums, part of the Development/Scripting category; I would like to know how to run a script file while linux boot (Linux Susie) . there is a ...


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

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 04-18-2007, 02:32 PM
Junior Member
User
 
Join Date: Apr 2007
Location: Noida, Delhi
My distro: Redhat, Fedora, suse
Posts: 3
Rep Power: 0
adhikari.rohit
Default Script file to be run when linux boot

I would like to know how to run a script file while linux boot (Linux Susie) . there is a file called serverStart.sh ,wht i have to do is run automattically while the Linux boot and when the linux shutdown it should run stopServer.sh . I hav tried with chkconfig but unable to do tht . So pLz help me to get out of it
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-22-2007, 10:50 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

put serverStart.sh in run level 2 / 3:
Code:
cp serverStart.sh /etc/rc2.d/
chmod +x /etc/rc2.d/serverStart.sh
put stopServer.sh in /etc/rc0.d
Code:
cp stopServer.sh /etc/rc0.d/
chmod +x /etc/rc0.d/stopServer.sh
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #3 (permalink)  
Old 05-12-2007, 03:49 AM
Junior Member
User
 
Join Date: May 2007
Posts: 8
Rep Power: 0
NVRAM is on a distinguished road
Default Script file to be run when linux boot

First, create a file called /etc/init.d/myserver with these contents (but fix the "/path/to" part):
Quote:
#! /bin/sh
case "$1" in
start) /path/to/startServer.sh ;;
stop) /path/to/stopServer.sh ;;
restart) /bin/sh $0 stop
/bin/sh $0 start ;;
*) echo "Usage: $0 {start|stop}"
exit 1 ;;
esac
Next, create symbolic links named S12myserver or K02myserver in each of the /etc/init.d/rc*.d/ directories: use the 'K' if you don't wish it in that run level, use the 'S' if you do.

Most likely, you'll want to start it in each run level 2 through 5 (only), but it depends on your situation.

Cheers.

PS: The '12' and '02' values in the link filenames are numbers that determine the order in which applications are started or stopped on runlevel changes. The values I gave should have your server started after most other services, and stopped before most others.
Reply With Quote
  #4 (permalink)  
Old 05-15-2007, 01:59 PM
Junior Member
User
 
Join Date: Apr 2007
Location: Noida, Delhi
My distro: Redhat, Fedora, suse
Posts: 3
Rep Power: 0
adhikari.rohit
Default

i hav tried wht u told me to doo but tht scripts doesn't run when system starts .
i want to run de script when system goes up..
Reply With Quote
  #5 (permalink)  
Old 05-15-2007, 09:44 PM
Junior Member
User
 
Join Date: May 2007
Posts: 8
Rep Power: 0
NVRAM is on a distinguished road
Default

Quote:
Originally Posted by adhikari.rohit View Post
i hav tried wht u told me to doo but tht scripts doesn't run when system starts .
i want to run de script when system goes up..
Please give all the details you can that might help us diagnose your problem; you'll be more likely to get help, and get it faster.

1. Sorry, I omitted that you need to make the script executable. Check/set it with:
ls -l /etc/init.d/myserver
chmod +x /etc/init.d/myserver
2. If the ls -l showed it was not be executable (ref) then step #1 will likely fix it.

3. Before you bother rebooting, try it manually from the command line, and if it doesn't work as expected, report the results:
/etc/init.d/myserver start
/etc/init.d/myserver stop
4. If that works, then reboot and then check the log files under /var/log -- especially boot.msg and maybe messages.

If you still have problems, show the output of ls -l for each script you have created or are calling, any output from log files and/or the console.

G'Luck
Reply With Quote
  #6 (permalink)  
Old 05-15-2007, 09:46 PM
Junior Member
User
 
Join Date: May 2007
Posts: 8
Rep Power: 0
NVRAM is on a distinguished road
Default

Actually, this may be a better reference for the executable, and other, mode bits:

http://www.linuxfocus.org/English/Ja....html#section1
Reply With Quote
  #7 (permalink)  
Old 05-22-2007, 01:05 PM
Junior Member
User
 
Join Date: Apr 2007
Location: Noida, Delhi
My distro: Redhat, Fedora, suse
Posts: 3
Rep Power: 0
adhikari.rohit
Default thx alot for ur cooperation.

ok i'll give u de brief deatails abt mi probs

1- there is a file called startServer.sh reside @ /opt/IBM/WebSphere/AppServer/bin and i have to run it manually in konsole as
./opt/IBM/WebSphere/AppServer/bin/startServer.sh

2 - what i want is that this script file should to be executed while system boots..

3 - so wht is the easiest way to do the above
Reply With Quote
  #8 (permalink)  
Old 05-22-2007, 08:59 PM
Junior Member
User
 
Join Date: May 2007
Posts: 8
Rep Power: 0
NVRAM is on a distinguished road
Default

Okay, a 60 second Google search pointed me to this:

Restarting on SUSE LINUX platforms

It's similar to what I posted, but provides more detaile info. And if it doesn't work you can probably call IBM support....
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
Linux boot partition ramjimh Linux software 1 03-24-2008 07:48 PM
File System Error During Boot svoltmer Ubuntu / Debian 3 02-21-2008 02:50 PM
problem with linux-2.6.12 kernel at boot time khadar Getting started tutorials 0 09-12-2007 04:38 PM
dual boot windows 2003 server and linux goku Windows Xp/2000/2003 server administration 2 07-17-2006 08:05 PM
Ubuntu Linux network installation using a boot server tom Getting started tutorials 1 07-13-2006 06:56 PM


All times are GMT +5.5. The time now is 07:22 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