Is it possible to put in "cod4_lnxded-bin 28970" for pidof, so it returns only the PID of the respective Port? I've got Bot-Servers and normal competition Servers and want them to have different priorities.
This will renice only the process which listens on port 28970 (regardless of
what kind of server it is). Simply repeat with different values for PORT to
handle more servers.
Note: This is just a quick-and-dirty solution I threw together. There are way
smarter ways of doing it, but this should work for your purpose.
It looks like as if it does not return the actual PID.
What is the output of the following (assuming your server actually runds on UDP port 28970)?
Code:
netstat -nlup| grep 28970
I'm leaving on a hunting-trip soon and will be away for a couple of days, but you should be able to fix the issue yourself by adding each piped command in turn on the netstat-line in the script and making sure that it keeps zeroing in on the actual pid, which should be at the far right alongside the process name. If one of the steps doesn't do what you expect it to do, simply modify it slightly and rerun. 'man tr' and 'man cut' should help you out. If I don't check in before I leave: Good luck!
It is really quite simple: We're trying to get the number 14748, which is the pid.
First we run netstat -nlup. That command outputs all listening UDP-sockets on the form you posted. We pipe that output into grep, which searches for a line which includes ":28970", since that's the port we're looking for. That leaves us with this:
We wish to cut out the last section of this line, so let's try to split it on space (" "). Before we can do that, since there's differing number of spaces between the segments of text, let's reduce all sequential spaces to a single one by piping through the 'tr -s " "' command. That leaves us with this:
Now let's count. 14748 is on the 6th segment of text. So we cut the line in pieces with " " being the separator, and pick out the sixth segment: 'cut -d" " -f6'. We now have this:
Code:
14748/cod4_lnxded-b
Ok, let's do the same again, but this time we'll need to cut with "/" as the separator, and we want the first segment: 'cut -d"/" -f1. We now have the pid:
Code:
14748
We captured the output of the command by enclosing it in `, and stored the result to the variable pid. we can then pass it to renice: 'renice -5 ${pid}'
The whole difference here compared to my original script, which worked on my PC, is that we need to pick out the sixth segment from the first cut. So try this:
Grandmother lived in the vegetable garden outside the village. Archlord gold We are just riding a motorcycle off the road, black from the vegetable plots ran the fastest to meet us. Because we go to when they are already fast at noon, so let's eat. I finished the meal, we went out looking for black to play.
When I saw the black when it's like I feel it seems hungry.world of warcraft gold I went to took a steamed bun, and then breaking off a small piece of the next, it said: "The black, if we should want to eat then." Finish, I put bread and threw the air. Black look, at once erected the whole body up. Should first
pandora bracelet
All times are GMT + 10 Hours Goto page Previous1, 2
Page 2 of 2
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum