LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 08-19-2008, 11:20 AM   #1
trist007
Member
 
Registered: May 2008
Distribution: Slackware
Posts: 972

Rep: Reputation: 56
Where do I place startup scripts?


I've made a few shell scripts to load up some modules, etc. Where do I place the scripts to have them run during boot?
 
Old 08-19-2008, 11:36 AM   #2
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,781
Blog Entries: 1

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
For most distros, you put them in /etc/init.d and then use the chkconfig command to put links into the appropriate boot directories (/etc/rcX.d). Slackware is a little different in that you use /etc/rc.d. If you state what distro you're using we can probably be more specific.
 
Old 08-19-2008, 11:37 AM   #3
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
As Hangdog42 stipulated, Slackware uses the /etc/rc.d folder for its start-up scripts. Whereas Debian uses /etc/init.d.
 
Old 08-19-2008, 04:29 PM   #4
tredegar
Guru
 
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,007

Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
Some of us just put these scripts into /etc/rc.local (if this file exists on your distro, I suggest you read and use it)
 
Old 08-19-2008, 05:03 PM   #5
trist007
Member
 
Registered: May 2008
Distribution: Slackware
Posts: 972

Original Poster
Rep: Reputation: 56
Using Fedora 8, Debian 4.0, and BT3
 
Old 08-19-2008, 05:11 PM   #6
tredegar
Guru
 
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 6,007

Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
Quote:
Using Fedora 8, Debian 4.0, and BT3
So, is the file /etc/rc.local there or not?
Have you tried putting your scripts there?
Please don't expect us to do ALL your homework.
 
Old 08-19-2008, 05:13 PM   #7
felixk
Member
 
Registered: Jul 2008
Posts: 60

Rep: Reputation: 15
Quote:
Originally Posted by Hangdog42 View Post
For most distros, you put them in /etc/init.d and then use the chkconfig command to put links into the appropriate boot directories (/etc/rcX.d). Slackware is a little different in that you use /etc/rc.d. If you state what distro you're using we can probably be more specific.
It looks to me as though Debian might do it differently too.

The choices for both /stc/init.d and /etc/rc.local are overwhelming (see below for extract). Any additional advice?

I just want to run the "hdparm" command at boot.

In Debian Etch, The (edited) choices of the suggested locations are:

[felixk@ ~]$ locate rc.local
/etc/init.d/rc.local
/etc/rc.local
/etc/rc2.d/S99rc.local
/etc/rc3.d/S99rc.local
/etc/rc4.d/S99rc.local
/etc/rc5.d/S99rc.local
[felixk@ ~]$ locate init.d
/etc/init.d
/etc/init.d/alsa
/etc/init.d/alsa-utils
/etc/init.d/anacron
/etc/init.d/atd
/etc/init.d/avahi-daemon
/etc/init.d/bootclean

REMAINDER SNIPPED.

felixk
 
Old 08-19-2008, 05:30 PM   #8
trist007
Member
 
Registered: May 2008
Distribution: Slackware
Posts: 972

Original Poster
Rep: Reputation: 56
yeah in BT3 there's


/etc/rc.d/rc.0
/etc/rc.d/rc.4
/etc/rc.d/rc.6

So I would just place a command in an appropriate area of one of those files to run a script? So by placing a command to run a shell script in rc.4, this command would be run when I run init 4 or user mode 4?
Would I have to run chkconfig in this situation?

Also, there are

/etc/rc.d/rc0.d/
/etc/rc.d/rc1.d/
/etc/rc.d/rc2.d/
/etc/rc.d/rc3.d/
/etc/rc.d/rc4.d/
/etc/rc.d/rc5.d/
/etc/rc.d/rc6.d/

These are empty, but these are for daemons? How would I use these if I wanted a daemon running? Do I need to place a shell script in there to start a daemon?
 
Old 08-20-2008, 07:10 AM   #9
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,781
Blog Entries: 1

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
Quote:
So I would just place a command in an appropriate area of one of those files to run a script?
You could do it that way, however it becomes a pain to manage if you get several scripts. Hence the suggestion to use either rc.local or /etc/init.d. Also, at least with Fedora, there is a startup and a shutdown link in every one of those directories.

Quote:
So by placing a command to run a shell script in rc.4, this command would be run when I run init 4 or user mode 4?
Yes, that is right.

Quote:
Would I have to run chkconfig in this situation?
Again, for manageability you do want to look into what chkconfig does. You don't need to use it, but it is there to make life easier.

Quote:
These are empty, but these are for daemons?
No, those are there for the same reason the others are. Each of those are used to customize a runlevel. Granted, not all of them are used by all distros, but the intent is the same. If you want a daemon running in a specific runlevel, you need to have the script linked from the appropriate directory.
 
Old 08-21-2008, 04:59 PM   #10
felixk
Member
 
Registered: Jul 2008
Posts: 60

Rep: Reputation: 15
Wink

Quote:
Originally Posted by trist007 View Post
yeah in BT3 there's


/etc/rc.d/rc.0
/etc/rc.d/rc.4
/etc/rc.d/rc.6
Debian does do it differently!

Looking at the contents of the files - instead of just finding where
they are - helps.
http://linuxquestions.cachefly.net/i..._lq/icon12.gif

- the currently existing "/etc/rc?.d/S99rc.local" files just link to a
script in /etc/init.d;

- that script says "run /etc/rc.local - if it exists".


At present, it exists, but is empty.

Problem solved.

My thanks for the encouragements.

Felix
 
  


Reply


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mandriva startup scripts (need to add something to startup before X starts) thunderweasel Mandriva 3 01-01-2006 12:55 AM
Where do you place shutdown scripts? zer0halo Linux - Newbie 3 08-24-2004 03:43 PM
startup commands - where to place (Fedora) sokar Linux - Newbie 1 01-23-2004 02:27 AM
Suitable place to run bash scripts Skyline Programming 7 01-21-2004 07:37 PM
Good place to find scripts? twistedpair Linux - General 3 01-15-2004 01:15 PM


All times are GMT -5. The time now is 02:17 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration