Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Shells Virtual Desktop
BMail.ag - Secure Email Service
Server.net
CPLicense.net
VPS Server
Buy VPN
Vultr
VMs for AI
HostDare
ReliableSite White-Label Dedicated Hosting for Resellers
InterServer VPS
BMail.ag - Secure Email Service
Best VPN
High-Performance Bare Metal Server Solutions
Karvl.com
Server Mania Cloud Hosting
DataWagon Hosting
AlphaVPS Hosting
Evoxt.com
Clouvider
VPS Hosting with NVMe
Residential IPs in the US & 4G Mobile Proxies in EU & US with Unlimited Bandwidth
ReliableSite White-Label Dedicated Hosting for Resellers
Rabisu - Hosting Solutions
Shells Virtual Desktop
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Kill Processes Script

NeoonNeoon Community Contributor, Veteran

Hey,

Atm i am using that script to kill one gameserver


NAME="srcds"

echo "Trying to kill $NAME..."

PID=ps -e | grep $NAME | awk '{print $1}'

echo "Process id $PID. Trying to send the TERM signal..."

kill $PID

echo "Done."

But i want to run multiple gameservers, the only difference would be:

screen -adms gmod01 /home/gmod/Warserver/gmod/srcds_run -console -game garrysmod +map gm_flatgrass +maxplayers 28

screen -adms gmod02 /home/gmod/Build/gmod/srcds_run -console -game garrysmod +map gm_flatgrass +maxplayers 20


idea how to get exactly the pid of one from booth?

Comments

  • Use the -pidfile option srcds_run has.

  • You could just do "pkill screen" it would kill all the screen processes (assuming that you don't use screen for other applications.)

  • You can't run both game servers on the same IP/port.

    You should be able to use fuser to kill the game server listening on a specific port.

  • NeoonNeoon Community Contributor, Veteran

    @rds100 that happens when you copy text. But thanks i try the pidfile stuff

  • NeoonNeoon Community Contributor, Veteran

    srcds_run dosent work with pidfile because of screen any other idea?

  • @Infinity580 you could try something like

    ps -e | grep "/home/gmod/Warserver/gmod/srcds_run -console -game garrysmod +map gm_flatgrass +maxplayers 28" | grep -v grep | awk '{print $1}'
    

    And replacing the first grep with the full command / path for the other server, to get the other PID

  • NeoonNeoon Community Contributor, Veteran

    @xDutchy that dosent works, already tried : ./test: line 1: -e: command not found

  • Why don't you just run each server as a different user with group privileges and do pkill -u username

    Thanked by 1Neoon
  • DroidzoneDroidzone Member
    edited August 2014

    -

  • kill -9 $(pidof PROCESSNAME) 
    
  • @Infinity580 said:
    xDutchy that dosent works, already tried : ./test: line 1: -e: command not found

    It shouldnt be a seperate command, what result do you get when running the entire line from the command line instead of using the testscript?

  • NeoonNeoon Community Contributor, Veteran

    pkill method works, thankz.

  • This is my init.d script. Take a look.
    http://pastebin.com/s0G9XUv9

  • NeoonNeoon Community Contributor, Veteran

    @jamaica already using my own scripz also for detecting if a gameserver crashed.

  • It's very useful, thx Infinity580

Sign In or Register to comment.