Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


Search this Thread
Old 12-10-2009, 07:28 AM   #1
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??


Thanks a lot!
Old 12-10-2009, 07:40 AM   #2
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,658

Rep: Reputation: 1261Reputation: 1261Reputation: 1261Reputation: 1261Reputation: 1261Reputation: 1261Reputation: 1261Reputation: 1261Reputation: 1261
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:
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.



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

Rep: Reputation: 184Reputation: 184
This link might be worth reading.
Old 12-10-2009, 07:53 AM   #4
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,563
Blog Entries: 29

Rep: Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179
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, 07:58 AM   #5
LQ Newbie
Registered: Nov 2009
Posts: 10

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 01:39 AM
make a bash script start automaticly when system restart sezam2 Programming 1 04-04-2009 09:27 PM
AWK- processing data inside start/stop pairs but ignoring start/stop lines cliffoij Programming 2 10-15-2008 07:17 AM
Start and stop a bash script based on network activity? creativetweak Linux - Software 8 05-04-2008 11:28 PM
using cron to start and stop a bash script monty Linux - Software 2 03-20-2006 03:30 PM

All times are GMT -5. The time now is 11:16 PM.

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