LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices

Reply
 
Search this Thread
Old 04-17-2005, 11:34 AM   #1
Napalm Llama
Member
 
Registered: Nov 2004
Location: Bristol, UK
Distribution: Gentoo 2005.0
Posts: 224

Rep: Reputation: 30
Newbie question - running a script at boot time


Hullo there.

I've written a shell script to load up my wlan card - everything from modprobe to dhcpd - but at the moment I'm having to go into a root shell and run it manually.

How would I make it so that it runs when all the other hardware is initialised?

I use FC3.

[EDIT]
Oh dear... I didn't notice that Fedora forum. Can somebody move this, please?

Last edited by Napalm Llama; 04-17-2005 at 11:39 AM.
 
Old 04-17-2005, 11:47 AM   #2
wmakowski
Member
 
Registered: Oct 2003
Location: Ohio
Distribution: Fedora 18, 19, RHL 5.2
Posts: 546

Rep: Reputation: 43
See /etc/rc.d/rc.local

Bill
 
Old 04-17-2005, 11:48 AM   #3
Vookimedlo
Member
 
Registered: Jul 2004
Location: Czech Republic - Roudnice nad Labem
Distribution: Debian
Posts: 253

Rep: Reputation: 33
Put your script into /etc/rc.local. It will start at boot time.
 
Old 04-17-2005, 12:31 PM   #4
Napalm Llama
Member
 
Registered: Nov 2004
Location: Bristol, UK
Distribution: Gentoo 2005.0
Posts: 224

Original Poster
Rep: Reputation: 30
OK, that worked, but because it happens after everything else, various things (like ntpd) don't work properly.

I'm not afraid of doing fairly complicated configuration - I just need to know what to do.

Ideally it wants to be one of the first things to run, not one of the last... right?
 
Old 04-17-2005, 01:02 PM   #5
marcosdumay
LQ Newbie
 
Registered: Jan 2005
Distribution: Debian, testing
Posts: 19

Rep: Reputation: 1
I don't know with distro do you use, but most distros have some rcX.d directories at /etc or at /etc/something. Scripts on those dirs run on a specific order (the scipts at rcX.d where X is a number run on the natural order from 1 to 5).

Each one of those directories have files nammed as SXX* or KXX*, where XX is a 2 digit number. The scripts that start with K run first, receiving the argument "stop". Then, the scripts that start with S run, receiving the argument "start". The order that the K and S scripts run are given by their numbers, so it is K00*, K01*, ..., K99*, S00*, S01*, ..., S99*.

You need to discover where the scripts that depend on your are and make sure it runs first.
 
Old 04-17-2005, 01:46 PM   #6
Napalm Llama
Member
 
Registered: Nov 2004
Location: Bristol, UK
Distribution: Gentoo 2005.0
Posts: 224

Original Poster
Rep: Reputation: 30
Ah yes, I found those, but I wasn't quite sure how to use them.

I have directories 0 thru 6, which I'm assuming refer to the runlevels.

Thing is, my script runs and then stops - if something ran it with the argument 'stop', it would just run again.

...And I'm guessing this would happen every time I switched runlevels?
 
Old 04-18-2005, 11:02 AM   #7
marcosdumay
LQ Newbie
 
Registered: Jan 2005
Distribution: Debian, testing
Posts: 19

Rep: Reputation: 1
Quote:
Thing is, my script runs and then stops - if something ran it with the argument 'stop', it would just run again.
If it starts a service, you should name it SXX*, if it stops one, you should name it KXX*. If it just set some configuration, or anything that doesn't deal with deamons, you should name it SXX*. But the name is not so restrct, the only differences between them are the order of execution and the argument, any one will work fine (but your system will be hard to understand if you use a K script to start something or a S one to stop).

Quote:
I have directories 0 thru 6, which I'm assuming refer to the runlevels.
Yes, those directories refer to runlevels. There may also be a rcS.d that refer to runlevel S (the one that executes before 0), but I am not sure, because they usualy start at 1 (so, on your system, S may be 0). You put your script everywere you need it to run. So, if you need it to run once, before some others (that depend on it), put it on a place that will be reached before the others. If you need to run it every runlevel, put it on every runlevel, but remember that runlevel S always run, and that runlevels 1 to 6 run everytime you reach a runlevel bigger or equal to them. That mean, if your system is going untill runlevel 5, it runs, on that order, runlevels S, 0, 1, 2, 3, 4 and 5, so, it is very rare to need something on all of them. I would recommend you to put your script with a number as hight as possible (to make it execute as late as possible), so it interferes with as little others as possible. Runlevel S is special because, when you type linux single at Lilo prompt, you just run it, so, if you want your script to run even if you are on a single section, you need to put it there.

Also, notice that those directories only have symbolic links. This is the usual way to add scripts to them, the script is located at /etc/init.d and is linked from the directories that you want.
 
Old 04-18-2005, 01:08 PM   #8
Napalm Llama
Member
 
Registered: Nov 2004
Location: Bristol, UK
Distribution: Gentoo 2005.0
Posts: 224

Original Poster
Rep: Reputation: 30
OK, I think I understand it now.

The script in question sets up networking support, so I'll probably put it near the beginning of Runlevel 3.

Only one problem - I put it in an rcX.d directory before, named S07wlansetup I think, and it wasn't run. I think that was rc3.d, so what's going on there?
 
Old 04-19-2005, 03:11 PM   #9
marcosdumay
LQ Newbie
 
Registered: Jan 2005
Distribution: Debian, testing
Posts: 19

Rep: Reputation: 1
It should run. Maybe you put it on the wrong place (not in rcX.d), maybe you didn't set executable permission or maybe there something wrong with the script.
 
  


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
Running a script at a certain time... Slith(++1) Programming 3 10-04-2005 10:12 PM
running dhcpd at boot time Fritz_Monroe Slackware 6 06-16-2005 06:43 PM
How to Do the Following? Running Script at Boot-Time + Sending Mail LinuxGeek Linux - General 1 07-20-2004 12:06 AM
Stop boot script at boot time!! kmiles2 Linux - Newbie 1 02-23-2004 10:04 PM
Running scripts at boot time saintt Linux - Software 1 08-09-2002 05:03 AM


All times are GMT -5. The time now is 01:49 AM.

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