Scripts won't run at boot
Tom H
tomh0665 at gmail.com
Tue Mar 8 13:38:28 UTC 2011
On Tue, Mar 8, 2011 at 5:26 AM, Dotan Cohen <dotancohen at gmail.com> wrote:
>
> I have a short script that I use to run other scripts:
> #!/bin/bash
> /path/to/executable
> /path/to/anotherExecutable
>
> I need this script to run at boot. So I placed it in /etc/init.d and
> made it executable. However, it doesn't run! This on an Ubuntu 10.04
> machine. I tested on my own Kubuntu 10.10 machine, and it too doesn't
> run! Googling around I've read about how to turn it into a service and
> run it but that is a workaround: How does one have scripts run in
> modern Ubuntu? The fine manual [1] suggests that being in /etc/init.d
> (and being obviously executable) would be enough.
>
> Note that I also tried running this command that I found on some blog
> in the hopes that it would help, but it expects the script to be
> written as a service:
> update-rc.d myScriptName defaults
>
> [1] https://help.ubuntu.com/community/UbuntuBootupHowto
Whether on Ubuntu or any other /etc/init.d/yourscript"nix system, you
have to have start (and perhaps stop) symlinks to your script in
"/etc/rc*.d/". You can do that manually or, on Ubuntu, with
update-rc.d (you can probably use chkconfig if it's installed but I've
only used it on RH boxes).
Dropping an executable into "/etc/init.d/" and expecting it run at
boot isn't a question of "modern Ubuntu" and writing a proper init
script isn't a "workaround!" I can't find anything on the link that
you've posted that suggest that this is the case. Unfortunately, that
page doesn't explain that the "script" is supposed to be of a certain
format.
The simplest way to write a correctly-formatted init.d script would be
"cp /etc/init.d/rc.local /etc/init.d/yourscript" and edit you
"/etc/init.d/yourscript" to run the executables that you want to
launch.
You can also write an upstart script "/etc/init/yoursrcipt.conf". I
can't think of a simple .conf file that you could copy and edit
off-hand.
If you only need these executables to run at boot, it's simpler to add
your lines above to "/etc/rc.local".
More information about the ubuntu-users
mailing list