LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Run a command at start up that uses screen. (https://www.linuxquestions.org/questions/linux-newbie-8/run-a-command-at-start-up-that-uses-screen-4175482395/)

wh33t 10-27-2013 04:04 PM

Run a command at start up that uses screen.
 
Hey LQ,

I'm trying to make my new vps launch a minecraft server when the vm boots. I know this is probably pretty straight forward, but I want to run the minecraft server from a new screen, so that I can reattach to it when ssh into it later.

Normally I do

screen -S "mc-server" and this gives me a new screen with a prompt.

then I do

java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui

then I do

ctrl+a+d to exit the screen and then log out of putty.

Any tips in the right direction would be swell. thank you.

AlucardZero 10-27-2013 04:22 PM

Put this in your crontab
Quote:

@reboot screen -U -a -d -m java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui

Turbocapitalist 10-28-2013 09:36 AM

tmux
 
You can also do it in tmux in a similar manner:

Code:

@reboot tmux new-session -ds mc-server 'java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui'
Then to reconnect, it would be like this from the shell:

Code:

tmux attach -t mc-server
If you need to share the mc server with others, there are ways to make it read-only.


All times are GMT -5. The time now is 12:48 PM.