Jay Taylor's notes

back to listing index

touch /var/lock/subsys/local <<-- Why?

[web search]
Original source (www.linuxquestions.org)
Tags: linux touch-var-lock-subsys-local rc.local www.linuxquestions.org
Clipped on: 2017-01-05

Image (Asset 1/12) alt= 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.

You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!

Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.

Are you new to LinuxQuestions.org? Visit the following links:
Site Howto | Site FAQ | Sitemap | Register Now

If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.

Having a problem logging in? Please visit this page to clear all LQ-related cookies.


Image (Asset 2/12) alt=
Registered: Feb 2004
Location: Norman, OK
Distribution: Fedora, Core 2
Posts: 23

Rep: Image (Asset 3/12) alt=
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.
 
Image (Asset 4/12) alt=
Registered: Nov 2002
Location: pikes peak
Distribution: Slackware, LFS
Posts: 2,577

Rep: Image (Asset 5/12) alt=
/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..............
 
Image (Asset 6/12) alt=
Registered: Feb 2004
Location: Norman, OK
Distribution: Fedora, Core 2
Posts: 23

Original Poster
Rep: Image (Asset 7/12) alt=

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



Last edited by cl2imson; 02-09-2005 at 04:46 PM.
 
Image (Asset 8/12) alt=
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: Image (Asset 9/12) alt=
Typically this is used with bigger services such as database servers and so forth to make sure they are not started twice.
 
Image (Asset 10/12) alt=
Registered: Feb 2004
Location: Norman, OK
Distribution: Fedora, Core 2
Posts: 23

Original Poster
Rep: Image (Asset 11/12) alt=
Registered: Jan 2003
Location: Portland, OR USA
Distribution: Slackware, SLAX, Gentoo, RH/Fedora
Posts: 1,024

Rep: Image (Asset 12/12) alt=
Registered: Feb 2004
Location: Norman, OK
Distribution: Fedora, Core 2
Posts: 23

Original Poster
Rep:
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.
 
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:
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.
 
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:
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.
 
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:
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
}
 
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:
ah yes i see now.

thank you mr. bull, i preciate de help.

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

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

Rep:
Still Helpful After All These Years

Thanks from me, too.
 
  





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:49 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
  Latest Threads
  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration