Cannot get script to run at startup (tried all the simple answers)

Posted by Carey Head on Ask Ubuntu See other posts from Ask Ubuntu or by Carey Head
Published on 2012-06-20T02:05:54Z Indexed on 2012/06/20 3:23 UTC
Read the original article Hit count: 209

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.

© Ask Ubuntu or respective owner

Related posts about scripts

Related posts about startup-applications