Make screen start as Daemon for a Minecraft server
I didn't remember screen
having a daemon mode, apparently it does. Change the screen line for the following:
screen -dmS minecraft.start /home/phirephoenix/minecraft/bukkitserver/start_server.sh
The new parameter -dmS
"Start as daemon: Screen session in detached mode.", which is the combination of -d
-m
and the -S
that you are already using.
Related videos on Youtube
PhirePhoenix
Computer Sience student, just starting to look into unix for servers. Doing some web development, mostly backend. Looking to learn more.
Updated on September 18, 2022Comments
-
PhirePhoenix over 1 year
I made a script that runs fine manually, but can't get it to run with the description in How to start a script file on boot?. I have run
update-rc.d -f minecraft.start defaults
This is what my
/etc/init.d/minecraft.start
is like#!/bin/bash case "$1" in start) screen -S minecraft.start /home/phirephoenix/minecraft/bukkitserver/start_server.sh echo "Server started on screen minecraft" ;; stop) screen -X -S minecraft.start kill echo "Server shutting down" ;; *) echo "Usage: /etc/init.d/minecraft.start {start|stop}" exit 1 ;; esac exit 0 ~
As the script works, I won't be adding it, since it's the default.
And this is my startup log
/var/log/boot.log
Begin: Loading essential drivers ... done. Begin: Running /scripts/init-premount ... done. Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done. Begin: Running /scripts/local-premount ... done. Begin: Running /scripts/local-bottom ... done. done. Begin: Running /scripts/init-bottom ... done. fsck from util-linux 2.20.1 /dev/sda1: clean, 66452/4325376 files, 1205648/17301248 blocks * Starting configure network device [ OK ] * Starting Mount network filesystems [ OK ] * Starting Failsafe Boot Delay [ OK ] * Stopping Mount network filesystems [ OK ] * Starting Bridge socket events into upstart [ OK ] * Starting SMB/CIFS File Server [ OK ] * Starting configure network device [ OK ] * Stopping OpenSSH server [ OK ] * Starting OpenSSH server [ OK ] * Starting NetBIOS name server [ OK ] * Starting Mount network filesystems [ OK ] * Stopping Failsafe Boot Delay [ OK ] * Starting configure network device [ OK ] * Starting System V initialisation compatibility [ OK ] * Stopping Mount network filesystems [ OK ] * Starting SMB/CIFS File and Active Directory Server [ OK ] * Stopping cold plug devices [ OK ] * Stopping log initial device creation [ OK ] * Starting enable remaining boot-time encrypted block devices [ OK ] * Starting configure network device security [ OK ] * Starting configure virtual network devices [ OK ] * Stopping configure virtual network devices [ OK ] * Starting save udev log and update rules [ OK ] * Stopping save udev log and update rules [ OK ] Skipping profile in /etc/apparmor.d/disable: usr.sbin.rsyslogd * Starting AppArmor profiles [ OK ] * Stopping System V initialisation compatibility [ OK ] * Starting System V runlevel compatibility [ OK ] * Starting ACPI daemon [ OK ] * Starting save kernel messages [ OK ] * Starting automatic crash report generation [ OK ] * Starting regular background program processing daemon [ OK ] * Starting deferred execution scheduler [ OK ] * Stopping save kernel messages [ OK ] * Starting CPU interrupts balancing daemon [ OK ] * Starting crash report submission daemon [ OK ] * Starting domain name service... bind9 [ OK ] **<BIG BLANK AREA RIGHT HERE, DON'T GET IT>** **[screen is terminating]** **Server started on screen minecraft** apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName * Starting web server apache2 [ OK ] * Stopping System V runlevel compatibility [ OK ]
It does execute the echo inside start, but it also says screen is terminating.
What is causing this problem here? I run Ubuntu Server, it seems
screen
is installed and working.So new approach, using the upstart feature (or what I should call it). I kind of understood the runtimelevel things after some short googeling, and it should now start on one of the four runtimelevels i have set, or stop, on halt/reboot etc.
made
/etc/init/bukkit.conf
much like the one warlock made. All the # are added for commenting here, and are not on the actual script.description "Bukktiserver" author "[email protected]" start on runlevel [2345] stop on runlevel [016] pre-start script echo " * Bukkitserver started" # I don't know if this does anything at all end script exec sudo /home/phirephoenix/minecraft/bukkitserver/start_server.sh # Had to sudo, or else it would get permission denied. Any ideas?
Now I can start the server with typing sudo start bukkit, but it still does not run automaticly. bukkit is in my
initctl list
withbukkit stop/waiting
(For everyone wondering bukkit is a minecraft server software.)So. I use a .conf to make it a upstart service, want the script to run without me having to do anything (automaticly before any logon). Is there a problem with the actuall jarfile to be run is in my homefolder? I can't really remember if my homefolder is encrypted or not, but it might be. Could this be a problem? Will I have to use symlinks or something (if symlinks are almost like shortcuts, but it ain't?)
What am I missing here?
Ps: I has also removed the screen startup thingy, with update-rc.d remove.
-
Ludwig Schulze over 10 yearsYou don't need sudo since you are already running as root.
-
PhirePhoenix over 10 yearsStill won't run at startup though. Now suddenly the process killed itself without me telling it to aswell.. :/
-
Phill Pafford over 9 yearsdid you ever get upstart and screen working?
-
-
PhirePhoenix over 10 yearsSo, i have changed this, and now my boot log seems to be happy, but still no active mc server. Trying to figure out if there is a active "screen" with this running, or where it should be running. But havn't found anything yet. Cause i would guess that the problem is the screen software now right?
-
PhirePhoenix over 10 yearsNow it might be the script actually. Seems like the script got broken somehow..
-
Ludwig Schulze over 10 years@PhirePhoenix if you run
screen -dmS minecraft.start /home/phirephoenix/minecraft/bukkitserver/start_server.sh
in a terminal, manually, does the desired effects happens? -
PhirePhoenix over 10 yearsWhen I ran the command manually as you asked it does excactly what it is supposed to. It starts the minecraft server in the background and i can close my terminal windows without minecraftserver stopping. What am I missing here? :S (I fixed the .sh script by the way, so that should not be an issue anymore)
-
Ludwig Schulze over 10 years@PhirePhoenix wait, how exactly doesn't work?
-
PhirePhoenix over 10 yearsI want it to start at boot. The minecraft-server doesn't start when i boot. But i can run the line manually to get it to work. So it's only the part where i can reboot the physical ubuntu-server, and the software minecraft-server to start automaticly. The log kindof say it has started. But i can't find the screen for it, and i cannot connect to the minecraft server. (Which I can when i run it manually).
-
PhirePhoenix over 10 yearsit is init.d and update-rc.d that is for use for automatic start on system startup, right? Is it a issue that the user who runs this is probably root, and I am on another user?
-
n.st over 10 yearsAlso, running anything with root privileges when you don't have to is really bad practice (and a potential security risk). Since you're running Ubuntu, you can use start-stop-daemon to start your screen session as some non-root user.
-
Ludwig Schulze over 10 years@PhirePhoenix is probable. Maybe you should consider
-
PhirePhoenix over 10 years@n.st It doesn't stop screen anymore (fixed with the -dmS I think) (at least not in log). How am i supposed to make something run at server startup, if not root? And the script runs perfectly good alone, or through screen, it just doesn't start at server-startup, which is what I want it to do. :/ Why is this so hard? Doesn't make sense at all.
-
PhirePhoenix over 10 years@Braiam What should I consider?
-
n.st over 10 years@PhirePhoenix You can use
su
or (preferably, in this case)start-stop-daemon
to execute a command as a different user. The init.d script would still run as root, but the Minecraft server wouldn't. -
Ludwig Schulze over 10 years@PhirePhoenix ups, err, maybe you should consider using upstart instead. There's an answer below the one you linked and also it allows you to switch users easily
-
PhirePhoenix over 10 years@n.st Aha! Okay, I will try this after i finish fixing a computer! I'm hoping to use start-stop-daemon to run screen maybe? I like the concept of screen. And it would be sweet to get to the minecraft server console fast for administration.
-
PhirePhoenix over 10 years@Braiam I will check it out, can't belive I missed it, must have been tired.
-
PhirePhoenix over 10 years@Braiam The solution you refered to, is for server with gui. I have no gui, nor do i intend to install one.
-
Ludwig Schulze over 10 years@PhirePhoenix you sure? I'm talking about warlocks which is valid as long as you use upstart.
-
PhirePhoenix over 10 years@Braiam Aaaah! I thought it was a comment further down. Will check that out aswell. What is the runtime he is talking about? Don't know what that is.
-
PhirePhoenix over 10 years@Braiam I have tried the upstart thing now, but still can't get it to run properly. I have added info in the question.