SRCDS Steam group


Stop a server using SSH?
#1
Is it possible to stop a server using SSH? What is the command?
Reply
#2
in the server console, ctrl + c will kill it, or if you know the pid (you can get this via ps aux) just do "kill thetasknumber"
Reply
#3
log in on the server and type this

ps awwux | grep src

finish with <ENTER>

the line between awwux and grep is the key with <> and AltGr + that key gives |

Good luck !
Reply
#4
Wrote a script. Using it for ages now. This is how it works:

- Connect to the server with SSH (using a prog like Putty)
- Type: vi <scripname you want>.scr
- Paste source below and fill in IP of your server. Check the gamepath! Save this script.
- You can use it:

./<scriptname>.scr start
Server starts and checks for updates

./<scriptname>.scr stop
Server stops

./<scriptname>.scr fast
Server starts without het updatecheck

./<scriptname>.scr status
Gives status of server (running/ not running)

This is the script:

#!/bin/sh
#-------------------------------------------------------
# COUNTER-STRIKE SOURCE START/STOP/RESTART/STATUS SCRIPT
#-------------------------------------------------------
# Start dit script met een van de volgende
# parameters: start/ stop/ restart/ status
#-------------------------------------------------------
# Door: Arjen
# Datum: 18-02-2005
#-------------------------------------------------------
# VARIABELEN
#-------------------------------------------------------
PATH=/bin:/usr/bin:/sbin:/usr/sbin
DIR=/usr/steam/srcds_l
PROC=27015
NAME="Counter-Strike Source Public Server"
PARAMETERS="+maxplayers 16 +map de_dust2 +log on +ip <IP> -console -autoupdate -verify_all -tickrate 100 -port 27015"
PARAMETERS2="+maxplayers 16 +map de_dust2 +log on +ip <IP> -port 27015 -console -verify_all -tickrate 100"
#-------------------------------------------------------
case "$1" in

start)
if [[ `ps -ef | grep $PROC|grep srcds` ]]
then
echo "Can't start $NAME. Status: online"
else
echo "Starting $NAME"
if [ -e $DIR ];
then
cd $DIR
./srcds_run $PARAMETERS &
else
echo "$DIR doesn't exist"
fi
fi
;;

stop)
if [[ `ps -ef | grep $PROC|grep srcds` ]]
then
echo "Killing $NAME"
kill -9 `ps -ef |grep $PROC |awk '{print $2}'`
else
echo "$NAME is OFFLINE"
fi
;;

restart)
if [[ `ps -ef | grep $PROC|grep srcds` ]]
then
echo "Killing $NAME"
kill -9 `ps -ef |grep $PROC |awk '{print $2}'`
else
echo "$NAME is OFFLINE"
fi
echo "Starting $NAME"
if [ -e $DIR ];
then
cd $DIR
./srcds_run $PARAMETERS2 &
else
echo "$DIR doesn't exist"
fi
;;

fast)
echo "Fast starting $NAME"
if [ -e $DIR ];
then
cd $DIR
./srcds_run $PARAMETERS2 &
else
echo "$DIR doesn't exist"
fi
;;

status)
ps aux | grep -v grep | grep $PROC|grep srcds> /dev/null
CHECK=$?
[ $CHECK -eq 0 ] && echo "$NAME is ONLINE" || echo "$NAME is OFFLINE"
;;

*)
echo "Start with parameters: $0 {start|stop|status|restart|fast}"
exit 1
;;
esac
exit 0




Good luck!
Reply
#5
Thank you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)