Script under rc3.d Vs rc.local


 
Thread Tools Search this Thread
Operating Systems Linux Script under rc3.d Vs rc.local
# 1  
Old 06-18-2009
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  
Old 06-18-2009
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  
Old 06-18-2009
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  
Old 06-19-2009
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  
Old 07-14-2009
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  
Old 07-14-2009
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  
Old 07-14-2009
Quote:
Originally Posted by mark54g
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
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Except script to run a local shell script on remote server using root access

local script: cat > first.sh cd /tmp echo $PWD echo `whoami` cd /tmp/123 tar -cvf 789.tar 456 sleep 10 except script: cat > first #!/usr/bin/expect set ip 10.5.15.20 set user "xyz123" set password "123456" set script first.sh spawn sh -c "ssh $user@$ip bash < $script" (1 Reply)
Discussion started by: Aditya Avanth
1 Replies

2. Shell Programming and Scripting

Running Local Script from SSH with SUDO

Hello, I know for SSH'ing and running a local script is... ssh -t user@servername < /path/to/localscript.sh and with SSH'ing and SUDO'ing is... ssh -t user@servername "sudo -u username ls -l /home/username" My inquiry is how can I combine both, by SSH'ing and SUDO'ing but running... (4 Replies)
Discussion started by: WPGPoseidon
4 Replies

3. Shell Programming and Scripting

To run a local shell script in a remote machine by passing arguments to the local shell script

I need to run a local shell script on a remote machine. I am able to achieve that by executing the command > ssh -qtt user@host < test.sh However, when I try to pass arguments to test.sh it fails. Any pointers would be appreciated. (7 Replies)
Discussion started by: Sree10
7 Replies

4. Shell Programming and Scripting

Execute a local script against a remote server

I am unable to run the below script against a remote server due to syntax error (then unexpected), but i am able to run it locally. Am i executing it correctly or is there any other way to execute it. ssh username@servernname ksh -s < scriptname #!/bin/ksh function record { ((end =... (5 Replies)
Discussion started by: NarayanaPrakash
5 Replies

5. UNIX for Dummies Questions & Answers

Global - Local script??

Hi, I have a script which can be called from any path on the machine. It kind of acts like a global script. How do I achive this? :confused: The path from which I call it is different from the path where it exists. (where <script name> ) Thanks and Regards, Preetham R. (1 Reply)
Discussion started by: preethgideon
1 Replies

6. Shell Programming and Scripting

Perl script 'system' linking to local shell script not working

Trying to figure out why this works: printpwd.pl #!/usr/bin/perl use CGI::Carp qw( fatalsToBrowser ); print "Content-type: text/html\n\n"; $A = system("pwd"); $A = `pwd`; print "$A\n"; ^^actually that works/breaks if that makes any sense.. i get the working directory twice but when... (5 Replies)
Discussion started by: phpfreak
5 Replies

7. Linux

Script under rc3.d not being executed on server bootup

Hello all, I have a script callled 'ABCstartup' setup under /etc/rc.d/init.d Softlink 'S91ABCstartup' pointing to above script has been created under /etc/rc.d/rc3.d The script is not being executed when the server restarts. The script runs successfully via manual execution:... (5 Replies)
Discussion started by: hemangjani
5 Replies

8. Shell Programming and Scripting

How to stop a script running in remote server from local script

Hi, I have googled for quite some time and couldn't able to get what exactly I am looking for.. My query is "how to stop a shell script which is running inside a remote server, using a script"??? can any one give some suggestions to sort this out. (1 Reply)
Discussion started by: mannepalli
1 Replies

9. Shell Programming and Scripting

ksh in rc3.d startup script

Hi there , Can someone tell me whether ksh is available in rc3.d,ie will it work if i add an korn shell script in rc3.d when the system starts up ? (1 Reply)
Discussion started by: JayNick
1 Replies
Login or Register to Ask a Question