LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Any idea how to start a script only at boot ? (https://www.linuxquestions.org/questions/linux-general-1/any-idea-how-to-start-a-script-only-at-boot-839940/)

Xeratul 10-23-2010 04:11 AM

Any idea how to start a script only at boot ?
 
I have found on the net the solution (debian testing)

to add this /etc/init.d/myscript
Code:

### BEGIN INIT INFO
# Provides:          myscript
# Required-Start:    $remote_fs $syslog
# Required-Stop:    $remote_fs $syslog
# Default-Start:    2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start script at boot time and stop at shut down
# Description:      Enable service provided by daemon.
### END INIT INFO


######update-rc.d myscript defaults
# enter code below

and then it makes it as rc2.d but however it starts it when I turn off the pc too :(

repo 10-23-2010 04:29 AM

Did you run
Quote:

update-rc.d
Take a look at
http://embraceubuntu.com/2005/09/07/...run-at-bootup/

Kind regards

Xeratul 10-23-2010 07:04 AM

Quote:

Originally Posted by repo (Post 4136656)
Did you run

Take a look at
http://embraceubuntu.com/2005/09/07/...run-at-bootup/

Kind regards

surely ... i ran update.rc

but this method rc2.d results in running the script too at boot + at shutdown of the machine (so both :()
Only boot would be so gorgeous though

Quote:

So you have a script of your own that you want to run at bootup, each time you boot up. This will tell you how to do that.

Write a script. put it in the /etc/init.d/ directory.
Lets say you called it FOO. You then run

% update-rc.d FOO defaults

You also have to make the file you created, FOO, executable, using
$chmod +x FOO

You can check out
% man update-rc.d for more information. It is a Debian utility to install scripts. The option “defaults” puts a link to start FOO in run levels 2, 3, 4 and 5. (and puts a link to stop FOO into 0, 1 and 6.)

Also, to know which runlevel you are in, use the runlevel command.


All times are GMT -5. The time now is 10:42 AM.