Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am running a stupid little minecraft server.

I want Lubuntu to execute the following script when the server boots up. NOT on login, and NOT on restart (unless it's starting up of course).

The script is currently located in:


I can manually launch the script by just going into the dir and typing ./craftbukkit.sh. But I want to fire off the script when the machine boots.

share|improve this question
Is that a daemon or onetime script ? – warl0ck Aug 7 '12 at 5:58
@warl0ck: daemon. craftbukkit is the name of the server, and includes a shell script for executing it as it's a java application. – Matthew Scharley Aug 7 '12 at 6:20
up vote 5 down vote accepted

I run a minecraft server from a debian terminal, and this is probably the wrong way to do it, but it works. First, sudo apt-get install screen, then save the following script as /etc/init.d/minecraft:

case "$1" in
    screen -S minecraft /home/mc/server/craftbukkit.sh
    echo "Server started on screen minecraft"
    screen -X -S minecraft kill
    echo "Server shutting down"
    echo "Usage: /etc/init.d/minecraft {start|stop}"
    exit 1

exit 0

Now, run the following commands as root:

update-rc.d -f minecraft defaults

This will make the minecraft server run in the background when the system boots. To view the console, run screen -x minecraft in a terminal. To quit the console, press Ctrl+A and then D.

share|improve this answer
If this fails you, you can clean up by removing the following files: /etc/init.d/minecraft /etc/rc0.d/K01minecraft /etc/rc1.d/K01minecraft /etc/rc2.d/S01minecraft /etc/rc3.d/S01minecraft /etc/rc4.d/S01minecraft /etc/rc5.d/S01minecraft /etc/rc6.d/K01minecraft /etc/rcS.d/S01minecraft – Suchipi Aug 7 '12 at 4:55
I'm sure there's an easier way to setup the symlinks, but I haven't used ubuntu in a while. This is the right approach though. – Matthew Scharley Aug 7 '12 at 6:19
@MatthewScharley update-rc.d is the right way to do with old-style init scripts – warl0ck Aug 7 '12 at 6:28
Sometimes update-rc.d complains about this init script, but I didn't know about the -f option. Thanks, @warl0ck – Suchipi Aug 7 '12 at 6:32
@ppumkin init.d scripts are run as root. When I used this in the past on my own minecraft server, everything lived in /root/minecraft. – Suchipi Oct 15 '13 at 1:20

On latest Ubuntu, you should do it like this, create /etc/init/bukkit.conf (whatever .conf),

description     "Some java server"
author          "Moi <moi@x.com>"

start on runlevel [2345]   # change start / stop level if needed
stop on runlevel [016]

pre-start script
   echo "script is abort to start"
end script

exec /path/to/script param1 param2

post-start script
   echo "script is started" # if you needed any post-start hack
end script

More information here.

share|improve this answer

in ubuntu/lubuntu there should be a menu item called "startup applications". On my ubuntu server it is under the 'system > preferences > startup applications' menu. That is in gnome but it should be smiler. Choose the add button and give it a name like minecraft and make sure the box it checked for it to start.

this may not be a hard core linux solution but it provides an easy way to see if it is enabled and to disable/enable it when you want to.

share|improve this answer
Unfortunately, this does not start the script at boot, only when you log in. – daniel kullmann Aug 7 '12 at 7:11
true but was going for a simplistic response as usually do when it comes to ubuntu variants or as I call them windows of the Linux world. – Joe Aug 7 '12 at 7:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.