Created
September 23, 2020 20:05
-
-
Save aschuhardt/0765f10edf733946d69cd1f825421b69 to your computer and use it in GitHub Desktop.
script to kill a minecraft server that was launched with launch_ftb.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ ! -f /tmp/ftb-session-name ]; then | |
echo "No session found! Was the server launched?" | |
exit 1 | |
fi | |
command_prefix="screen -S $session_name -p 0 -X stuff " | |
crontab_file="/tmp/.cronjobs-$(date '+%s')" | |
session_name="$(cat /tmp/ftb-session-name)" | |
# dump existing cron jobs to file | |
crontab -l > $crontab_file | |
# clean up any cron jobs from prior runs | |
sed --in-place '/ftb-server-/d' $crontab_file | |
# load cron jobs and remove temp file | |
crontab $crontab_file | |
rm $crontab_file | |
# stop the server if it's running | |
screen -S $session_name -p 0 -X stuff 'say stopping the server in 10 seconds...^M' | |
sleep 10 | |
screen -S $session_name -p 0 -X stuff 'stop^M' | |
rm /tmp/ftb-session-name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
script for starting: https://gist.github.com/aschuhardt/2694861f662e9b08f58641b1e1c5734f