How can I start program on boot in Ubuntu 14.04?

17,738

Solution 1

There are more than one way to accomplish this.

  1. You can put your startup script in /etc/init.d and make it resemble to one of the existing scripts over there. But depending on your Linux comfort level, this may be a little daunting.

  2. You can make this a service and make the service start at the boot time. Just do a google search on "how to make my program a service" and you will come across a lot of pages. More than what you can shake a stick at.

  3. If your app is startin g with one single command and is not dependent on anything else, you can add the start-up command at the end of /etc/rc.local file.

You can also put it in the cron to execute at the startup but this is not the way it should be done, in my opinion

Solution 2

Ubuntu normally has Vixie cron installed. You can use @reboot for a normal user's crontab file. From the man page:

Instead of the first five fields, one  of  eight  special  strings  may
appear:

          string         meaning
          ------         -------
          @reboot        Run once, at startup.
          ....
Share:
17,738

Related videos on Youtube

Daniel T
Author by

Daniel T

Updated on September 18, 2022

Comments

  • Daniel T
    Daniel T over 1 year

    Is the root crontab the only way? I'm starting up a MC server and don't want it to need me to manually restart it each time the server reboots for whatever reason. I don't want any login required for these programs to initialise.

    I'm using ssh to get into this server, it's a VPS, nothing local.

  • Daniel T
    Daniel T about 8 years
    The advice I was given was to add this to the crontab... @reboot cd ~/McMyAdmin && screen -dmS McMyAdmin ./MCMA2_Linux_x86_64 ...but sadly it didn't work. :(
  • Daniel T
    Daniel T about 8 years
    Thanks! The original advice I was given from a web page was to run the following... @reboot cd ~/McMyAdmin && screen -dmS McMyAdmin ./MCMA2_Linux_x86_64 ...sadly it didn't work using my non-root account.
  • Anthon
    Anthon about 8 years
    You should at least expand the paths (not use ~). Or better make a script in which you do everything, assuming your PATH is only /usr/bin:/bin and then call that script from the crontab.