LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-10-2009, 06:28 AM   #1
melmar
LQ Newbie
 
Registered: Nov 2009
Posts: 10

Rep: Reputation: 0
start script bash when system start,stop,reeboot, how ??


Hi, I have 3 script BASH.

I want start this script when the system start,stop and reeboot.

Can I do it??

How??

Thanks a lot!
 
Old 12-10-2009, 06:40 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Make a script called foo that takes the arguments start, stop and restart. Put it in the directory /etc/init.d/

Here I'm assuming that your default runlevel is 2 (Debian and I guess Ubuntu default), so make a link:
Code:
ln -s /etc/init.d/foo /etc/rc2.d/S99foo
At boot time this script will be called with the "start" argument, at shutdown with the "stop" argument. Have a look at the other scripts in /etc/init.d/ and google for inspiration.

Cheers,

Evo2.

Last edited by evo2; 12-10-2009 at 06:40 AM. Reason: Typo
 
Old 12-10-2009, 06:41 AM   #3
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
This link might be worth reading.
http://tldp.org/HOWTO/From-PowerUp-T...t-HOWTO-6.html
 
Old 12-10-2009, 06:53 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
The boot script system varies from distro to distro. In a system using /etc/init.d/ and /etc/rc[0-6S].d/ directories it is the K* symlinks that are run with the "stop" argument during shutdown. Which distro are you using?
 
Old 12-10-2009, 06:58 AM   #5
melmar
LQ Newbie
 
Registered: Nov 2009
Posts: 10

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by catkin View Post
Which distro are you using?
I use Ubuntu 9.10
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script start gedit but don't stop there Watchin Linux - General 7 10-30-2009 12:39 AM
make a bash script start automaticly when system restart sezam2 Programming 1 04-04-2009 08:27 PM
AWK- processing data inside start/stop pairs but ignoring start/stop lines cliffoij Programming 2 10-15-2008 06:17 AM
Start and stop a bash script based on network activity? creativetweak Linux - Software 8 05-04-2008 10:28 PM
using cron to start and stop a bash script monty Linux - Software 2 03-20-2006 02:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration