0

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:

#!/bin/bash
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 '12 at 3:09
  • When I test script /etc/init.d/myscript start it works but it doesn't start on startup – star Jun 5 '14 at 8:30
1

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

0

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.

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.