LinuxAnswers - the LQ Linux tutorial section.
Go Back > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Debian This forum is for the discussion of Debian Linux.


  Search this Thread
Old 11-30-2010, 04:59 PM   #1
Senior Member
Registered: Jun 2006
Location: Debian Land
Posts: 1,593

Rep: Reputation: 111Reputation: 111
Fighting with making running a script at startup only but not at shutdown/reboot ...


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

# 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.

here my script below
then how to make it work only for the startup only (so,ie at power on)?
sudo update-rc.d mystartupscript defaults
Many thanks if someone has any ideas how to perform such complicate procedure ...
Old 11-30-2010, 06:04 PM   #2
Senior Member
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Originally Posted by Xeratul View Post
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:
case "$1" in
        # Do startup
        # Do nothing
        # Print usage or do nothing
Old 12-01-2010, 03:21 AM   #3
Registered: Nov 2010
Distribution: Debian Lenny
Posts: 136
Blog Entries: 1

Rep: Reputation: 23
This link may help a bit. 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.
Old 12-01-2010, 09:08 AM   #4
Registered: Feb 2007
Location: VA, USA
Distribution: CentOS, Fedora
Posts: 53

Rep: Reputation: 4
Why do they make this so difficult in Debian based distros? I'm not bashing, just wondering what the reasoning behind it is.
Old 12-01-2010, 02:04 PM   #5
Registered: May 2007
Distribution: Ubuntu 14.04 LTS
Posts: 62

Rep: Reputation: 17
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.
Old 12-01-2010, 02:13 PM   #6
Registered: Nov 2010
Location: Minneapolis, MN
Distribution: Ubuntu, Red Hat, Mint
Posts: 128

Rep: Reputation: 30
Perhaps I misunderstand the question...

...but can't you do this using @reboot in cron?


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Init.d script not executing at shutdown and reboot roberbizimhatemo Linux - General 13 05-04-2012 08:28 AM
Unable to shutdown/reboot server, no shutdown process running dctw Linux - Server 5 03-31-2010 06:46 AM
Shutdown and Reboot Linux System via php script ramasubbu1984 Linux - Newbie 7 03-24-2009 10:09 AM
Run script on shutdown or reboot VeeDubbs Linux - Server 1 10-23-2008 02:34 PM
Require key for shutdown/reboot or startup krock923 Linux - Security 2 08-06-2006 09:02 PM

All times are GMT -5. The time now is 09:15 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration