The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Operating Systems > Linux
.
google unix.com



Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
rsh help - getting the output of remote script to local server. aster007 Shell Programming and Scripting 5 03-07-2009 10:14 AM
How to stop a script running in remote server from local script mannepalli Shell Programming and Scripting 1 03-04-2009 08:18 PM
Executing shell script on local machine jakSun8 Shell Programming and Scripting 4 07-02-2008 01:32 PM
How to make variables in script function local? alex_5161 Shell Programming and Scripting 5 03-07-2008 02:03 PM
Shell script to create local homes Steve Adcock Shell Programming and Scripting 11 10-25-2004 04:18 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-18-2009
hemangjani hemangjani is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 73
Script under rc3.d Vs rc.local

Which of the following gets executed first?

script under rc3.d Vs script under rc.local

I was under impression that rc3.d has higher precedence over rc.local. Somehow it looks like the script under rc.local got executed first than the one under rc3.d.

I had to manually start them in order for the application to work.

any suggestions?
  #2 (permalink)  
Old 06-18-2009
mark54g mark54g is offline
Registered User
  
 

Join Date: May 2008
Posts: 359
rc.local or boot.local, depending on the distribution is run before any runlevel is reached. rc3.d runs a script only when runlevel 3 is reached. Why would you assume rc3.d has priority?
  #3 (permalink)  
Old 06-18-2009
hemangjani hemangjani is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 73
Mark,

Thank you for the response. I can't recall on how I started assuming that runlevel scripts have priority.

While I was searching online in regards to when rc.local, many sites have listed that rc.local gets executed every time a runlevel changes.

"Every time runlevel changes" - Is this during the boot process?

---------- Post updated at 04:58 PM ---------- Previous update was at 04:14 PM ----------

It seems like rc.local is being executed multiple times:

./rc2.d/S99local
./rc3.d/S99local
./rc4.d/S99local
./rc5.d/S99local
  #4 (permalink)  
Old 06-19-2009
mark54g mark54g is offline
Registered User
  
 

Join Date: May 2008
Posts: 359
what does S99local correspond to? The distro I use, SUSE, has boot.local, which takes the place of rc.local for them, and it is executed before a runlevel is reached.

---------- Post updated at 11:11 AM ---------- Previous update was at 10:55 AM ----------

An introduction to services, runlevels, and rc.d scripts

If this all still sounds a bit too complicated, you can instead simply make use of the /etc/rc.d/rc.local file. This script file is run once, before all other scripts have run but before the logon prompt appears. By default it looks something like:

#!/bin/bash## /etc/rc.local - run once at boot time

# Put any local setup commands in here:
  #5 (permalink)  
Old 07-14-2009
sixstrings sixstrings is offline
Registered User
  
 

Join Date: Jan 2005
Posts: 33
rc.local is the last thing run after the run level is reached. That is why under the rc.d directories it is listed with the 99. It is the last to run.

If you create a script to run under the rc.d/ directories, you have to assign it a number and it will run in order.
  #6 (permalink)  
Old 07-14-2009
mark54g mark54g is offline
Registered User
  
 

Join Date: May 2008
Posts: 359
Please read the link I submitted. You are wrong, Six. rc.local is executed before anything else

More proof:
http://www.fedorafaq.org/basics/

Q: How do I run something when the computer starts?
A: You have two choices, either you can run something before anybody logs in, or you can run something immediately after you log in.

To run a command right after you boot, before anybody logs in, add the command to the file /etc/rc.local:
  #7 (permalink)  
Old 07-14-2009
mglenney mglenney is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 85
Quote:
Originally Posted by mark54g View Post
Please read the link I submitted. You are wrong, Six. rc.local is executed before anything else
Actually Mark, sixstrings is right. rc.local is generally the last startup script to run at any run level. Your example from the Fedora site spells it out:

"To run a command right after you boot, before anybody logs in, add the command to the file /etc/rc.local:"

The OP asked which runs first, script under rc3.d or scirpt "under" rc.local. I put under in quotes because in the Redhat server I'm looking at right now rc.local is a script, not a directory. On top of that the question is weird because rc.local is one of the scripts that is executed if you go to run level 3.

The scripts executed when a run level is applied have symbolic links in /etc/rc.d/rc<number>.d/ and have a name like S<number><name>. The scripts are executed by /etc/rc.d/rc which, if you look at it, just runs them through a for loop. The are executed in alphabetical order so S01blah gets executed before S02blah which gets executed before S02blat. The symbolic link for rc.local is usually S99local which puts it "near" the end. I say "near" because, while it's inteded to be at the end, it's possible to have scripts execute after it. You can do that by creating a symbolic link named S99<something_aphabetically_after_local>.

MG
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 06:32 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0