UBUNTU bukkit boot script

Discussion in 'Server & Community Management' started by wumpyc, Jun 2, 2013.

  1. Hello.
    Just bought a dedicated server from OVH with Ubuntu installed on it.. So now I have a folder /minecraft and inside minecraft.sh with the following code:
    Code (Text):
    java -Xmx8192M -jar craftbukkit.jar
    I can now run the server by doing "cd minecraft" and then ". minecraft.sh".
    I would like UBUNTU to do the same thing when it boots up, so I don't have to run the server again every time I reboot.
     
  2. How often do you reboot the server?
     
  3. Well, I just got it. I'm not even sure I will be rebooting it much, but I though that performance goes down after a while without reboot, doesn't it?
     
  4. No.
    Welcome to the wonderful world of Linux where uptime means everything.

    If you really are that worried, look into an init script or something, i tried a crontab idea with someone yesterday and it didn't work sooooo, best bet is your init.d.
     
  5. You might want to install MSM (http://www.msmhq.com) if you're not interested in any web control panels. It also acts like an init script. Mark2 also does it (can't remember the URL for that one).
     
  6. My dedicated Linux machine hasn't seen a reboot in ~3 years and it still runs like a champ, no performance decrease xD
     
  7. I doubt a Minecraft server from 3 years ago would still be running though :p
     
  8. I believe he's talking about the actual machine, although I highly doubt that it's possible to keep a server running for 3 year straight.
     

  9. He was talking about the actual machine, he's asking how to auto-start the server when Ubuntu restarts, but I swear to you my Linux machine has been up that long xD
     
  10. Impossible. Show us an uptime output.
     
  11. I know, hence I said "though" :p
    3 years ago I doubt there was a stable enough version to run for more than half a year, and even then, it would be outdated...

    Personally, I don't think there is much wrong with daily Minecraft restarts. Just choose your least popular time and the server will normally only be down for a few mins. Probably not needed, but shoot me.
     
  12. Hmm, you were right, apparently there were a few power outages at the host whilst I wasn't paying attention xD, kudos to EncryptedCurse. But LukeHandle, I haven't been noticing any instabilities nor have any been reported to me, and I'm running Ubuntu Server 10.04.4 LTS :p.

    21:35:44 up 438 days, 47 min, 2 users, load average: 1.71, 1.10, 0.84

    EDIT: nonetheless, Linux doesn't require or suffer from a deficiency of frequent restarts to a rather large extent, as Windows does ;)
     
  13. I meant the Minecraft server instance again - sorry for all the confusion :confused:
     
  14. Ah yes the actual Java process for Minecraft is restarted daily xD.
     
  15. vemacs

    Artist

    sudo nano /etc/crontab
     
  16. If you choose to go the cron route (as per vemacs suggestion), then add the line:
    Code (Text):
    @reboot  /path/to/minecraft.sh
    Worth noting, if you normally run the script as a non privileged user (advised for security reasons), then you will need to put a sudo in your script (minecraft.sh) so that cron runs it as the specified user.

    All that follows only applies to when a different user runs the instance...

    Code (Text):
    sudo -u spigot java -Xmx8192M -jar craftbukkit.jar
    or
    Code (Text):
    su spigot -c "java -Xmx8192M -jar craftbukkit.jar"
    or just execute your cron with a sudo:
    Code (Text):
    @reboot  sudo -u spigot /path/to/minecraft.sh
    Assuming that you have a user called 'spigot'.

    Or in fact, thinking about it, the correct way for user based crontabs is for them to be made properly.
    Code (Text):
    crontab -u spigot -e
    Will create a crontab for the user 'spigot' that will be executed by 'spigot'.