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. – Diamant Nov 11 '15 at 17:33
  • a simple script that starts a node process, starts a php etc... – yarek Nov 11 '15 at 17:34
  • I count 9 lines, not 30. And they're comments, not shell script (and not SSH script). – wurtel Nov 12 '15 at 13:27
  • 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! – kristopolous Jun 10 '16 at 10:47

If your script is "just a script", and doesn't start a daemon, consider using /etc/rc.local (executed as root) or crontab (executed as a user of your coice).

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

Edit 1: Just read your comment: If your script starts daemons, which should run all the time, 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.

Edit 2: You call it crazy, but 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: 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 '15 at 18:01
  • @yarek: It works, using this myself (for scripts, which are just scripts). – gf_ Nov 11 '15 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 '15 at 18:15
  • btw i was talking about debian ! – Froggiz Nov 11 '15 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 '15 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.


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.