1838675 Members
4959 Online
110128 Solutions
New Discussion

System reboot

 
Jeff Hagstrom
Regular Advisor

System reboot

When the machine reboots, there is a file(s) that gets processed, sort of like autoexec.bat. I want to add something to be run everytime the machine gets rebooted. Where and which file?
8 REPLIES 8
Patrick Wallek
Honored Contributor

Re: System reboot

There is not a single file that gets run, there are a bunch of them.

What you are thinking of are the KILL scripts in /sbin/rc?.d. If you want to add something to the shutdown you will have to create a new shutdown script that gets exectued at the appropriate run level.

Tom Maloy
Respected Contributor

Re: System reboot

You can add a start-up script in /sbin/init.d, and link to it from /sbin/rc3.d.

Follow the model of start files named with "S" as the first char. Also include handling for parameters "start_msg" and "start".

If you need this at shutdown as well, another link with "K" as the first char, and handling for "stop_msg" and "stop".

Tom
Carpe diem!
Martin Johnson
Honored Contributor

Re: System reboot

You could try to put an entry in /etc/inittab. See man inittab for details.

HTH
Marty
S.K. Chan
Honored Contributor

Re: System reboot

You need 2 files and 2 symbolic link for this purpose.
1) /sbin/init.d/yourprogram
==> Make use of the file "template" in /sbin/init.d to customize your startup/shutdown program script.
2) /sbin/rc[0->4].d
==> Depending on at which run level you want your program to startup/shutdown. Create the appropriate symbolic link back to /sbin/init.d/yourprogram. For example to start at run level 3, you would ..
S999->/sbin/init.d/yourprogram
and to stop at run level 2, you would ..
K099->/sbin/init.d/yourprogram
3) /etc/rc.config.d/yourprogram
==> Not actually the same file but rather the file that has the CONTROL_VARIABLE defined, so that to disable/enable the script you can simply turn the 0 or 1 bit. This var is checked everytime /sbin/init.d/yourprogram runs.
MANOJ SRIVASTAVA
Honored Contributor

Re: System reboot

Hi Jeff


The noraml level after the system reboots is 3 , so to include the files like you do in autoexec.bat you need to put the files in /sbin/init.d and link to /sbin/rc3.d



Manoj Srivastava
Sean OB_1
Honored Contributor

Re: System reboot

You are looking for the startup and shutdown scripts.

The scripts are placed in /sbin/init.d

then you link to them from /etc/rcN.d

Typically you'll put the script you want to run at boot in /etc/rc3.d with the following naming convention.

/etc/rc3.d/SNNNyourscriptname

where NNN is a number between 001-999
The system executes them in alpha order so S001abc runs before S999abc.

If you want a script to run at shutdown you'll put it in /etc/rc2.d with the following naming convention.

/etc/rc2.d/KNNNyourscriptname


You link the script using the follwing command.

ln -s /sbin/init.d/yourscriptname /etc/rc3.d/SNNNyourscriptname

HTH

Sean
melvyn burnard
Honored Contributor

Re: System reboot

have a read of start_up.txt in /usr/share/doc

This discusses the methodology of doing exactly this.,
My house is the bank's, my money the wife's, But my opinions belong to me, not HP!
Fred Martin_1
Valued Contributor

Re: System reboot

As an aside, I set up a script to page me (via email to my pager) whenever the system reboots. I set it up exactly as S.K.Chan describes above except I have no control variable file:

/sbin/init.d/boot.alert
(the script file)

/sbin/rc3.d/S400boot.alert
(a link to the script file)

When my system reboots, I get the email page, but I get it twice.

Not sure why I get it twice.
fmartin@applicatorssales.com