LinuxQuestions.org
Help answer threads with 0 replies.
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 02-08-2005, 12:34 PM   #1
cl2imson
LQ Newbie
 
Registered: Feb 2004
Location: Norman, OK
Distribution: Fedora, Core 2
Posts: 23

Rep: Reputation: 15
Question touch /var/lock/subsys/local <<-- Why?


Hello world. I am nicely adapting to the Linux world, and find a new challenge everyday - which I actually kind of enjoy, as it helps me gain a better understanding of Linux, and what it does.

I was reading up on runlevels, init, rc.d, and other boot processes, when I came across one I just ca't seem to solve. Any comments or corrections would be welcome, as this one is driving me bonkers.

I must clarify, this is not an emergency, just one of those things that I can't seem to google successfully, and I have perused quite a few docs to no avail.

During boot up, after init takes over, it implements the inittab and starts all the processes, yada yada yada.

I have read that the last file acted upon by init is /etc/rc.d/rc.local

Am I correct thus far?

Soooo, being the curious lion I am, i noticed that the only action in this file is:

Code:
touch /var/lock/subsys/local

My questions are two. The second one is somewhat subjective, so I will start with the easy straightforward one first:

1. What does this command do FOR the system? (I am using Fedora Core 2) I understand the concept of touch, but what is this actually doing or checking or setting? And why (if it even is) is this touch command on that particular file necessary?


2. What kind of cool things can I do with this /etc/rc.d/rc.local file? Ideas, suggestions, experiences?


btw
Thanks to all you peeps out there who make learning this new way of life so fun and remarkably easy to understand. These forums and website is a tremendous aide, and have solved countless other hiccups along the way.

Last edited by cl2imson; 02-08-2005 at 12:50 PM.
 
Old 02-08-2005, 12:48 PM   #2
320mb
Senior Member
 
Registered: Nov 2002
Location: pikes peak
Distribution: Slackware, LFS
Posts: 2,577

Rep: Reputation: 48
In Slackware this is actually::

/etc/rc.d/rc.local
this is used for any local commands you want started ......

I put the parameters for hdparm which enables DMA..........
Also I use the emu10k1 driver from sourceforge for my SB Live sound card.........so I also put a line in to mobprobe the module so sound works when KDE fires up..............
 
Old 02-09-2005, 12:41 PM   #3
cl2imson
LQ Newbie
 
Registered: Feb 2004
Location: Norman, OK
Distribution: Fedora, Core 2
Posts: 23

Original Poster
Rep: Reputation: 15
that sounds good. i assume you get to hear startup music when launching x?


btw, still would like an answer to my first question, if anybody knows...



Last edited by cl2imson; 02-09-2005 at 04:46 PM.
 
Old 02-09-2005, 08:57 PM   #4
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
What this does is create a lock file that tells the system that 'local' is up and running already. It prevents the script from being run twice, as it will fail until the lockfile is removed, which will happen when you shut down.

Typically this is used with bigger services such as database servers and so forth to make sure they are not started twice.
 
Old 02-10-2005, 06:56 AM   #5
cl2imson
LQ Newbie
 
Registered: Feb 2004
Location: Norman, OK
Distribution: Fedora, Core 2
Posts: 23

Original Poster
Rep: Reputation: 15
thank you bulliver, i was about to pull mah hairs out trying to figure this one out.
 
Old 02-10-2005, 07:10 AM   #6
Darin
Senior Member
 
Registered: Jan 2003
Location: Portland, OR USA
Distribution: Slackware, SLAX, Gentoo, RH/Fedora
Posts: 1,024

Rep: Reputation: 45
Basically, any command you want to have run when your system starts can go in rc.local. Typically, for me, I put stuff in here if/when I'm not sure what other startup procedure is supposed to do what I want. As an example, I used to have a line in rc.local to do some touch up networking commands that I now have in the startup script for my firewall since they are more appropriate there, but either place is fine. As you learn about new things in Linux, the rc.local script is a good place to load them until you figure out what other startup script to put them in.
 
Old 02-10-2005, 03:25 PM   #7
cl2imson
LQ Newbie
 
Registered: Feb 2004
Location: Norman, OK
Distribution: Fedora, Core 2
Posts: 23

Original Poster
Rep: Reputation: 15
darin,

excellent suggestion about placing things that i don't know where to put but want to play around with still. thx!

Not knowing where to put something is half the battle.

do you know what kind of program would check that aforementioned file? and what it might be checking for< just the existence of?

peace.
 
Old 02-10-2005, 03:35 PM   #8
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
Nothing 'checks' for rc.local. It is simply the last rc script run before you arrive at a login prompt when booting...therefore, it is a good place to put commands you need run at boot that don't warrant their own full-blown rc script.
 
Old 02-10-2005, 04:16 PM   #9
cl2imson
LQ Newbie
 
Registered: Feb 2004
Location: Norman, OK
Distribution: Fedora, Core 2
Posts: 23

Original Poster
Rep: Reputation: 15
hmmm, maybe beter put like this.

rc.local is the last script run by init.

within that script (at least fc2) is the command

Code:
touch /var/lock/subsys/local
once that file is created, from what i have read in this post, notifies the 'system' that local has been run once.

what i would like to know is what app would look for that file (./local) to be in that (var/lock/sybsys/) directory?

i do understand the workings of rc.local now though.
 
Old 02-10-2005, 04:44 PM   #10
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
I see what you mean. To tell the truth I don't think anything looks there. I have never seen a lock mechanism in place for the rc.local script. Like I was saying, usually it is only used for bigger services. However, it is usually checked by the script itself.

If you have a look at one of your more complicated rc scripts you may see in the 'start' function something like (pseudo code):
Code:
start() {
    if /var/lock/subsys/myapp exists; then
        echo "myapp already started"
        exit
    else
         touch /var/lock/subsys/myapp
         /command/to/start/myapp
    fi
}
 
Old 02-11-2005, 06:43 AM   #11
cl2imson
LQ Newbie
 
Registered: Feb 2004
Location: Norman, OK
Distribution: Fedora, Core 2
Posts: 23

Original Poster
Rep: Reputation: 15
ah yes i see now.

thank you mr. bull, i preciate de help.

have a great weekend!
 
Old 03-30-2010, 09:45 PM   #12
dmxjo
LQ Newbie
 
Registered: May 2009
Posts: 1

Rep: Reputation: 0
thank you guys for the Questions and the answers really it helped me to understanding rc.local what for ...
 
Old 06-26-2011, 03:35 PM   #13
prh47
LQ Newbie
 
Registered: Jun 2011
Posts: 6

Rep: Reputation: 2
Still Helpful After All These Years

Thanks from me, too.
 
  


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
E: Could not get lock /var/lib/dpkg/lock - open (11 Resource temporarily unavailable) phreakshew Linux - Newbie 17 07-12-2016 03:50 AM
How does minicom write to /var/lock Wim Sturkenboom Linux - General 2 10-26-2005 04:28 AM
subsys lock? Travis_NOOB Fedora 0 09-28-2005 05:51 PM
/var/lock/subsys/ stefaandk Linux - Newbie 2 07-21-2005 08:27 PM
Error - can't touch touch: /var/lock - filesystem problem? xanas3712 Linux - Newbie 0 05-10-2004 06:26 AM


All times are GMT -5. The time now is 12:52 PM.

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