Execute a program as the very last step of Linux boot process
Linux - SoftwareThis 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
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.
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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).
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
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.
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.
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?
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)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.