Upstart script with command in screen as specified user

My brother runs his own minecraft server. He would like to have it started after boot up, inside a screen, as his own user. The way, he can reattach the screen and do administration on the minecraft server. The server runs a minimal install of Debian.

Add this to rc.local

# Upstart for minecraft server
# change directory
cd /home/minecraft
# start server inside screen as user minecraft
su minecraft -c "screen -d -m java -Xms950M -Xmx950M -jar minecraft_server.jar nogui"

Make rc.local executable

chmod +x /etc/rc.local

If “-d -m” is omitted in the screen command, it will try to attach to a tty. This will fail, either because it does not have access to root’s tty, or because no tty exists.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>