UBUNTU: can I run startup script only (not on shutdown)?
I'm trying (& failing) to write a script in /etc/init.d that only operates on boot up but NOT on shutdown.
The program I want to run does not accept any parameters. This works Code:
#!/bin/bash This doesn't Code:
#!/bin/bash Obviously my newb systax but I can't see what is wrong :( |
Hello,
As far as I know starting and stopping programs/scripts at startup/shutdown is not handled by /etc/init.d/ but by linking them in the appropriate (runlevel directory(ies)) in /etc/rcX.d where the X is the runlevel. Scripts to start begin with the letter S followed by a number that indicates in what order processes will be started. Scripts to stop begin with a K and a number that indicates in what order processes will be stopped (killed). In Debian based you can create those links to your script with the update-rc.d command. Code:
update-rc.d /path/to/script defaults Code:
man update-rc.d Kind regards, Eric |
I overlooked something!
Thanks, EricTRA but I'd already been through that loop.
That's how I new it would run at shutdown. I said it was running at startup also and in one way I was correct but "moveit" wasn't getting any response. "moveit" requires the LAN to be up and running, specifically eth0 with a static IP. It appears that by trying to run "moveit" at startup is prior to LAN initialisation. So now I need to dig out where to put "moveit" knowing the LAN has been initialised. |
Hi,
Then put the startup sequence number at the end in the runlevel directory, like this: Code:
S99yourscript Kind regards, Eric |
Thanks agin.
But I'd done that too :( I put it at 90 with update-rc.d -f movitaction start 90 2 3 4 5 . so It's still too early. When does the NIC actually get initialised? |
Hi,
I'm not sure but are you running a graphical interface with Ubuntu (like Gnome) or only console? I think that if you're using a graphical interface that network is managed by the network manager and thus started after the init routine. Kind regards, Eric |
Quote:
I'm still running Breezy, (OK, old but still works :) ), in 'kiosk' mode. And of course you're right since if I (manually) wait until the GUI is loaded I can issue "moveit" command without a problem. What I need is a script which waits until the network is started. I tried in ~/.xinitrc but that doesn't work either :( |
Hello,
You could always put an 'if' statement in your script to check if the NIC is up or not and act accordingly (sleep for x seconds and then try again). That way your script will go into a loop until the NIC is up and only then execute. Kind regards, Eric |
Quote:
If I put the script in /init.d will it not hold up the boot process even if I give it a 99 priority? Is the NIC initialised concurrently or after all the init.d scripts have completed? Will ~/.xinitrc accept bash script? OK, OK, I'll look around... :) |
All times are GMT -5. The time now is 11:35 PM. |