I am running a 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.

  • Is that a daemon or onetime script ?
    – daisy
    Aug 7, 2012 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. Aug 7, 2012 at 6:20

4 Answers 4


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.


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.

  • 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, 2012 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. Aug 7, 2012 at 6:19
  • @MatthewScharley update-rc.d is the right way to do with old-style init scripts
    – daisy
    Aug 7, 2012 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, 2012 at 6:32
  • 1
    @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, 2013 at 1:20

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.

  • Unfortunately, this does not start the script at boot, only when you log in. Aug 7, 2012 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, 2012 at 7:15

Docker I prefer to create Dockerfile and run it with --restart=always tag

If you want to run your shell script on boot Then use unix's crontab It's very easy to use & you can configure in minutes

  1. Edit crontab run the following replacing the "USER" with your desired runtime user for the node process. If you choose a different user other than yourself, you will have to run this with sudo.

    $ crontab -u USER -e

  2. Once in the editor add the following line:

    @reboot sh /home/mc/server/craftbukkit.sh

  3. Save & confirm file is saved by check command of #1 again

    Note: In my opinion, you should use the full path in crontab file to prevent issues

You can refer this URL reference Ubuntu Cron HowTo

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.