Dex Posted December 18, 2012 Share Posted December 18, 2012 How I can stop the server when it is running? Please, help ... OS: Debian 6.0 (x86) Link to comment
uhm Posted December 19, 2012 Share Posted December 19, 2012 if its still the active process (so you can still see whats being said and whatnot) simply press CTRL+C or type command: exit if you ran it via "screen", which is the method you should use for running mta-server, check out part 3 (My Connection Dropped - What Can I Do?) of this page: http://www.howtoforge.com/linux_screen and then type command: exit to do it dramatically you can type ps to view current processes. the first column is the process id. this is what you use for: pkill Link to comment
Phat Looser Posted December 27, 2012 Share Posted December 27, 2012 Shellscript: #!/bin/bash # # Minecraft Server Launcher # # chkconfig: 35 90 12 # description: Launcher for Minecraft modified to work with MTA # author: original Dragonshadow, modified by BigBadButler, stolen by someone-else-whose-name-i-won't-mention-cause-he's-not-important # # source function library SERVER_IDENT="$1" SCREEN_NAME="MTA_SERV_"$SERVER_IDENT GAME_PATH="/emul/ia32-linux/mta-servers/$SERVER_IDENT/" SERVER_FILE="mta-server" message() { echo "Server should show message now $1" screen -D -r $SCREEN_NAME -p 0 -X stuff "say $1"`echo -ne '\015'` } start() { if [[ $(ps fxa | grep $SCREEN_NAME | grep SCREEN | awk '{ if ($1 != "") print $1 ;}') = "" ]]; then # cd $GAME_PATH #ausführen von Screen um den Server zu starten screen -S $SCREEN_NAME -d -m $GAME_PATH$SERVER_FILE # cd echo "Server Started" else echo "Server Already Running" fi } stop() { if [[ $(ps fax | grep $SCREEN_NAME | grep SCREEN | awk '{ if ($1 != "") print $1 ;}') = "" ]]; then echo "Server not found or Offline" else screen -D -r $SCREEN_NAME -p 0 -X stuff "say Shutdown in 5 second(s)"`echo -ne '\015'` sleep 1 screen -D -r $SCREEN_NAME -p 0 -X stuff "say Shutdown in 4 second(s)"`echo -ne '\015'` sleep 1 screen -D -r $SCREEN_NAME -p 0 -X stuff "say Shutdown in 3 second(s)"`echo -ne '\015'` sleep 1 screen -D -r $SCREEN_NAME -p 0 -X stuff "say Shutdown in 2 second(s)"`echo -ne '\015'` sleep 1 screen -D -r $SCREEN_NAME -p 0 -X stuff "say Shutdown in 1 second(s)"`echo -ne '\015'` sleep 1 if ! [[ $(ps fax | grep $SCREEN_NAME | grep SCREEN | awk '{ if ($1 != "") print $1 ;}') = "" ]]; then PID=`ps fax | grep $SCREEN_NAME | grep SCREEN | awk '{ print $1 }'` kill $PID fi echo "Server Stopped" fi } restart() { backup sleep 5 stop start echo -e "Server Restarted" } status() { if [[ $(ps fax | grep $SCREEN_NAME | grep SCREEN | awk '{ if ($1 != "") print $1 ;}') = "" ]]; then echo "Server offline or crashed... Restarting" $0 start screen -X $SCREEN_NAME -X exec .\!\! echo save-all else echo "Server Online" fi } check() { #awk '{ if ($1 != "") print $1 ;}': Sorgt dafür, dass das erste Wort gefunden wird. Wenn das erste Wort "" ist, bedeutet das, dass die Liste leer ist. Oder: Der Prozess läuft nicht. if [[ $(ps fax | grep $SCREEN_NAME | grep SCREEN | awk '{ if ($1 != "") print $1 ;}') = "" ]]; then echo "Server Offline" else echo "Server Online" fi } case "$2" in start) start ;; stop) stop ;; status) status ;; check) check ;; message) message "$3" ;; restart) stop start ;; *) echo $"Use: $0 {start stop status check restart}" exit 1 esac exit 0 You need to modify it a bit, but: ./server.sh ./server.sh Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now