I have Ubuntu Desktop 12.04 LTS running great on an older Acer desktop. I want to use this machine as an in-home server for hosting Minecraft.

The command to start the Minecraft server is java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui and that works great when I cd into the correct directory and execute the above.

I created a script to do this:

cd /home/myuser/minecraft-server1
java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui &
cd /home/myuser/minecraft-server2
java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui &
exit 0

I made this .sh file executable, and it too runs great when I start it manually from the terminal.

The problem I'm having is getting these to execute at startup. I have my user account on this machine to auto login.

I have tried the following:

  • Adding the following to "Startup Applications" : sh /home/myuser/myscript.sh (Nothing happens on reboot)
  • Adding the same to /etc/rc.local (Nothing happens on reboot). I even tested this one by running /etc/rc.local from the terminal, and it executed great. Just not at boot/auto login
  • Added the lines from the script directly to rc.local (Nothing happens on reboot).

I can't help but think that there's something I'm missing. The script executes great when run manually, but will not run at boot/auto login.

Many thanks in advance.

  • instead of changing directory then running, run java -Xmx1024M -Xms1024M -jar /home/myuser/minecraft-server1/minecraft_server.jar nogui & and java -Xmx1024M -Xms1024M -jar /home/myuser/minecraft-server2/minecraft_server.jar nogui &. Does that work??
    – Five
    Jun 20, 2012 at 3:09
  • When I test script /etc/init.d/myscript start it works but it doesn't start on startup
    – star
    Jun 5, 2014 at 8:30

2 Answers 2


startup and shutdown scripts are usually stored in /etc/init.d

Once your script is in the correct location, run the following commands

chmod +x /etc/init.d/myscript

update-rc.d myscript defaults

Check to see if your script is able to start correctly with the command

/etc/init.d/myscript start


In Ubuntu 12.10 if you hit the super key(windows key), and type in "startup applications" and hit enter a window will pop up that will enable you to add a start up program.

Click "add" and in the "Command" field enter the location of your script. That should work.

  • Doesnt work with .py scripts Sep 29, 2021 at 6:51
  • @SavannahMadison The Python script will need a shebang line and must be marked as executable. Then, it should run the same as any command.
    – Jason
    Sep 30, 2021 at 12:43
  • Tried that.It still doesnt run on startup even though I can manually execute it through the terminal Oct 6, 2021 at 3:05

You must log in to answer this question.

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