I have a Debian server and I just need to run a script at startup.

I read that: https://www.debian-administration.org/article/28/Making_scripts_run_at_boot_time_with_Debian

I got now: insserv: warning: script ' missing LSB tags and overrides

so it looks like I have to add now:

# Provides:          scriptname
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.

It looks now crazy: like 30 lines of script just to run a program at startup.

Is there a tool that allows to do that a simply way ?


  • What kind of a script it is? Have you tried to run it from /etc/rc.local? You can put the path to the script in rc.local file and it will be executed at boot time.
    – Diamond
    Nov 11, 2015 at 17:33
  • a simple script that starts a node process, starts a php etc...
    – yarek
    Nov 11, 2015 at 17:34
  • I count 9 lines, not 30. And they're comments, not shell script (and not SSH script).
    – wurtel
    Nov 12, 2015 at 13:27
  • 1
    They are LSB headers (see wiki.debian.org/LSBInitScripts) and an LSB init script boilerplate is north of 70 lines (see things like github.com/fhd/init-script-template/blob/master/template). If you want make a single command run by hand to be handled for you at boot by the computer through some file in /etc, this seems like quite an elaborate ceremony!
    – user535759
    Jun 10, 2016 at 10:47

3 Answers 3


Consider using /etc/rc.local (executed as root) or crontab (executed as a user of your choice).

Two examples:

  • /etc/rc.local

    #!/bin/sh -e
    #(Multiple lines of comments removed.)
    exit 0
  • crontab (edited via, for example, crontab -e)

    #(Multiple lines of comments removed.)
    @reboot /usr/local/bin/your-script.sh

If your script needs to run continuously in the background, I would advise against using rc.local or crontab, and instead write a proper (or multiple) init.d script(s). This way you / your system is able to cleanly restart/reload/start/stop etc. the daemons.

The LSB tags provide some value: "By documenting the run-time dependencies for init.d scripts, it becomes possible to verify the current boot order, order the boot using these dependencies, and run boot scripts in parallel to speed up the boot process." For more details, head over to the Debian wiki.

By the way, the missing headers: It's a warning, so actually, it's up to you, how and what to do with this.

  • I like the crontab version.. but I don't think @reboot works on debian !
    – yarek
    Nov 11, 2015 at 18:01
  • @yarek: It works, using this myself (for scripts, which are just scripts).
    – gxx
    Nov 11, 2015 at 18:07
  • 2
    it works, but i think it is only for root user, so you have to do @reboot root /usr/local/bin/your-script.sh
    – Froggiz
    Nov 11, 2015 at 18:15
  • btw i was talking about debian !
    – Froggiz
    Nov 11, 2015 at 18:30
  • I am still quite confused indeed: Does cron enable to run anyscript when server restarts, not opening sessions as root.
    – yarek
    Nov 11, 2015 at 20:30

supervisord is also an option. You will write again some lines in order to start your node.js and PHP stuff, but they will be fewer.

  • Except you then need cron or something else to start supervisord in the first place Jul 17, 2020 at 12:57
  • The Debian installer does this for you. I am under the impression that the OP do not want to write the 30+ lines themselves. Not that 30+ is an overkill by itself if done by somebody else.
    – adamo
    Jul 21, 2020 at 9:26
  • Interesting, I'm using Debian 9 and I had to manually setup supervisord to start a startup. However, I didn't have any issues once I'd done that. Comes back online now after a reboot Jul 21, 2020 at 14:12
  • I just tried with a vagrant debian/stretch64 box: sudo apt-get install supervisor installs and starts supervisord. Maybe you installed it via pip?
    – adamo
    Jul 22, 2020 at 13:00

You can use monitd for this, just write some monit definition and it will start daemons for you. But why you don't use proper way with LSB scripts? It's not so hard to write it (you're writting it just once) and it is the cleanest and most valuable way how to achieve this.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .