Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

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

Writer Sophia Terry

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.

2

2 Answers

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.

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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