LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (http://www.linuxquestions.org/questions/debian-26/)
-   -   Fighting with making running a script at startup only but not at shutdown/reboot ... (http://www.linuxquestions.org/questions/debian-26/fighting-with-making-running-a-script-at-startup-only-but-not-at-shutdown-reboot-847529/)

Xeratul 11-30-2010 03:59 PM

Fighting with making running a script at startup only but not at shutdown/reboot ...
 
Hello,

So I found many methods on google, but no one works. It seems that this one is THE Debian way.

Code:

### BEGIN INIT INFO
# Provides:          mystartupscript
# 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

######
here my script below

then how to make it work only for the startup only (so,ie at power on)?
Code:

sudo update-rc.d mystartupscript defaults
Many thanks if someone has any ideas how to perform such complicate procedure ... :(

David1357 11-30-2010 05:04 PM

Quote:

Originally Posted by Xeratul (Post 4176227)
then how to make it work only for the startup only (so,ie at power on)?

Just make it so that your init script only handles the "start" parameter:
Code:

case "$1" in
  start)
        # Do startup
        ;;
  stop)
        # Do nothing
        ;;
  *)
        # Print usage or do nothing
        ;;
esac


barriehie 12-01-2010 02:21 AM

This link may help a bit. http://wiki.debian.org/LSBInitScripts I've got a daemon that launches at boot time and it's called picsdaemond; the file that launches it is called picsdaemondctl. Picsdaemondctl is the file that is used with the update-rc.d command to update the init scripts.

x-nc 12-01-2010 08:08 AM

Why do they make this so difficult in Debian based distros? I'm not bashing, just wondering what the reasoning behind it is.

rdgreenlaw 12-01-2010 01:04 PM

For debian based systems you should have a skeleton file /etc/init/skeleton which shows the correct format for the procedure which starts or stops a service.

For the start function check for the existence of the lock file. If the lock file exists return 0, otherwise start the program, touch the lock file (to create it) and return 1

For the stop function check for the existence of the lock file. If the file does not exist return 0, otherwise kill the program, delete the lock file, then return 1

Setup the script to start in every runlevel except runlevel 0. This will activate the program only once to start it, and only stop it on runlevel 0. To shutdown without actually killing the program be sure to remove the lock file, otherwise starting the script at startup will do nothing since the lockfile is what is used to determine if a program needs to be started.

thesnow 12-01-2010 01:13 PM

Perhaps I misunderstand the question...
 
...but can't you do this using @reboot in cron?


All times are GMT -5. The time now is 04:02 PM.