LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-02-2011, 07:15 AM   #1
pmil
Member
 
Registered: Jul 2008
Posts: 43

Rep: Reputation: 15
Question Execute a program as the very last step of Linux boot process


Hi all,

I want to execute a program at the very last step of Linux boot process.

For Debian based Linux distro that uses BSD boot process, I came up with 2 solutions:

1) I should somehow call my program from the /etc/rc.local script (although is this the last step of the boot process?)
2) Use the "multi_end" and "sysinit_end" hooks for executing it at the end of rc.multi rc.sysinit respectively (I don't know how to do it though).

Any help will be much appreciated.
 
Old 02-02-2011, 09:21 AM   #2
aj4ck
LQ Newbie
 
Registered: Jan 2010
Posts: 3

Rep: Reputation: 0
The easiest would be from the rc.local script, just make sure your script does not go into a forever loop
 
Old 02-02-2011, 08:50 PM   #3
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,345
Blog Entries: 28

Rep: Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145
I have used rc.local quite successfully to do this in Slackware.

Never needed to do it on Debian, but my understanding is that that is exactly what rc.local is intended for.
 
Old 02-04-2011, 07:55 AM   #4
pmil
Member
 
Registered: Jul 2008
Posts: 43

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by aj4ck
The easiest would be from the rc.local script, just make sure your script does not go into a forever loop
Quote:
Originally Posted by frankbell View Post
I have used rc.local quite successfully to do this in Slackware.

Never needed to do it on Debian, but my understanding is that that is exactly what rc.local is intended for.
Thank you both for your responses. The reason I am not sure if rc.local is the last script called at the start-up process, is because I found some sites saying that:

Code:
http://www.netbsd.org/docs/guide/en/chap-rc.html
/etc/rc.local is almost the last script called at boot up.
So, is it the last or almost the last script called? As I mentioned, it is very important to me to call my program as the last step of the start-up process.

Thank you all for your help.
 
Old 02-04-2011, 08:20 AM   #5
KamasCZ
LQ Newbie
 
Registered: Jan 2011
Location: Czech Republic, Tyniste n. O.
Distribution: Slackware
Posts: 22

Rep: Reputation: 1
First, we need to know your distro, to be sure. Then, Init scripts are caled from one place and at the end of each script, another script is called.
Look in the /etc/rc.d or /etc/rc.xd (depending on your distro, x is the number of runlevel).

Basicaly, there is one script for each runlevel, that do everything.
On Slackware, it is rc.S for runlevel 1 (single user) and rc.M for runlevel 2 (multiuser) - rc.local is the last script that you can find in rc.M on Slackware.
 
Old 02-04-2011, 11:11 AM   #6
pmil
Member
 
Registered: Jul 2008
Posts: 43

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by KamasCZ View Post
First, we need to know your distro, to be sure. Then, Init scripts are caled from one place and at the end of each script, another script is called.
Look in the /etc/rc.d or /etc/rc.xd (depending on your distro, x is the number of runlevel).

Basicaly, there is one script for each runlevel, that do everything.
On Slackware, it is rc.S for runlevel 1 (single user) and rc.M for runlevel 2 (multiuser) - rc.local is the last script that you can find in rc.M on Slackware.
Thanks for your answer. I use Debian (lenny) but I would be interested in one more generic solution that applies to all distributions following the NetBSD start-up model. Is this possible or each distribution adjusts the start-up model to its needs?

The problem is that I can't find the 'rc.d' script under '/etc/' but I see an 'inittab' script that indicates AFAIK a System V start-up system. Because I see a bunch of /etc/rcX.d folders (each one having many scripts), I assumed that NetBSD is being used. Could someone please clarify?

Last edited by pmil; 02-04-2011 at 11:13 AM.
 
Old 02-04-2011, 11:57 AM   #7
KamasCZ
LQ Newbie
 
Registered: Jan 2011
Location: Czech Republic, Tyniste n. O.
Distribution: Slackware
Posts: 22

Rep: Reputation: 1
inittab means only that you are using init.
rcX.d directories means that you use System V.
I think this is normal in Debian.
In inittab, there should be instructions for init process, what to do in each runlevel.
In Slackware, there is:
Code:
# Default runlevel. (Do not set to 0 or 6)
id:3:initdefault:

# System initialization (runs when system boots).
si:S:sysinit:/etc/rc.d/rc.S

# Script to run when going single user (runlevel 1).
su:1S:wait:/etc/rc.d/rc.K

# Script to run when going multi user.
rc:2345:wait:/etc/rc.d/rc.M

# What to do at the "Three Finger Salute".
ca::ctrlaltdel:/sbin/shutdown -t5 -r now

# Runlevel 0 halts the system.
l0:0:wait:/etc/rc.d/rc.0

# Runlevel 6 reboots the system.
l6:6:wait:/etc/rc.d/rc.6

# What to do when power fails.
pf::powerfail:/sbin/genpowerfail start
In debian, the rc:3 should point to everything in /etc/rc3.d (via some util like run-parts)
 
  


Reply



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
DISCUSSION: Add a Program to the Applications Menu - A step-by-step tutorial ruguloo LinuxAnswers Discussion 2 04-16-2012 09:51 PM
Step by step procedure in replacing Red Hat 9.0 by Ubuntu in my dual boot XP/linux charliemerleau Linux - Software 1 10-04-2005 01:12 AM
How to execute a program whan boot juanb Linux - Software 1 05-20-2004 09:20 AM
need direction to step by step process dkretz Linux - Newbie 5 02-15-2004 06:58 PM
newbie How to install a program step by step help me waheedrafiq Linux - Software 8 08-06-2003 02:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:56 AM.

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
Open Source Consulting | Domain Registration