-
-
Notifications
You must be signed in to change notification settings - Fork 48
[Linux] Autostart into a screen.
Vincs edited this page Mar 4, 2021
·
5 revisions
- nodejs ^14 if your using SSS from source.
- Warning: it doesn't work well with Node installed by NVM. For this to work, it recommended to install with your package manager.
- SSS binary
- screen (install it using your package manager)
Both in the root of your server, in this example: /home/$USER/minecraft/server
A script to start the screen with the server inside it.
#!/bin/bash
folder=$(dirname "$0")
cd $folder
msg="$(date --iso-8601=seconds) ... Starting screen and server ... $(whoami) -> $(pwd) "
echo $msg
echo $msg >> start_screen.log
screen -S minecraft -d -m $folder/start.sh
msg="$(date --iso-8601=seconds) ... Done ... "
echo $msg
echo $msg >> start_screen.log
screen -ls
A script to start the server
#!/bin/bash
msg="$(date --iso-8601=seconds) ... Starting SleepingServer ... $(whoami) => $(pwd) "
echo $msg >> start.log
npm start
chmod +x *.sh
Add an entry to your startup using crontab
crontab -e
Add a new line pointing to your script file ( & means to detach from the process once started) Don't forget to point to your script / directory.
@reboot /home/$LOGNAME/minecraft/server/start_screen.sh &
You should be able to get back to your screen using
screen -r minecraft
There are other way to start a server like
- pm2
- autostart
- as a service
I let your find your preferred way. Don't hesitate to share your experiences.