More Linux Numpty Questions
Discussion
When you start an application from the terminal
Say mpd mpd.conf
Can you give that instance its own process name?
What I've basically got is a bash script which starts multiple instances of mpd:
mpd mpd.conf
mpd mpd2.conf
mpd mpd3.conf
etc
But when I go into top to monitor the processes (for loading analysis) I just got lots of mpd entries and I cant tell which one is which.
Probably really easy when you know how, trouble is, I dont...
Say mpd mpd.conf
Can you give that instance its own process name?
What I've basically got is a bash script which starts multiple instances of mpd:
mpd mpd.conf
mpd mpd2.conf
mpd mpd3.conf
etc
But when I go into top to monitor the processes (for loading analysis) I just got lots of mpd entries and I cant tell which one is which.
Probably really easy when you know how, trouble is, I dont...
if you do a
ps -aux | grep mpd
you'll just get a list of the mpd processes, this output will contain the the command it was launched from so you should be able to match the PID to the startup command.
then you can cross reference with top.
I'm sure there is a better way but this should get you going.
cheers
Ex
ps -aux | grep mpd
you'll just get a list of the mpd processes, this output will contain the the command it was launched from so you should be able to match the PID to the startup command.
then you can cross reference with top.
I'm sure there is a better way but this should get you going.
cheers
Ex
JamieBeeston said:
if there are only 3 of them, you could copy the binary 3 times over.
mpd.1
mpd.2
mpd.3
for example.
Another way is to cross reference the PID
J
There will be between 6 and 40 eventually but I keep forgetting that everything is a file in Linux and you can just copy stuff around with wanton abandoment.
that ps aux malarky seems to do what I need.
I'm sure theres a way to automate the process by doing that and then using sed on the ps output.
Seem reasonable?
Its top notch this Linux malarky.
All you need is some appropriate switches to the "ps" command;
ps -eaf | grep sleep
zumbruk 7993 7958 0 17:08 pts/2 00:00:00 sleep 999999999
zumbruk 7997 7958 0 17:09 pts/2 00:00:00 sleep 12345
zumbruk 7998 7958 0 17:09 pts/2 00:00:00 sleep 2345
zumbruk 8000 7958 0 17:09 pts/2 00:00:00 sleep 34567
As you can see, the parameters passed to the "sleep" commands are shown, so you can tell which one is which from that (I just ran "sleep 12345&"
So something like;
ps -eaf | grep sleep | grep -v grep | awk "{print $9}"
Will give you a list of jobs...
999999999
12345
2345
34567
You can print the process IDs too with "awk '{print $2,$9}'", and so on.
Feel free to drop me an email if you want any more help.
And if anyone's selling a track prepped Golf GTi, I'd like to know about that, too.
ps -eaf | grep sleep
zumbruk 7993 7958 0 17:08 pts/2 00:00:00 sleep 999999999
zumbruk 7997 7958 0 17:09 pts/2 00:00:00 sleep 12345
zumbruk 7998 7958 0 17:09 pts/2 00:00:00 sleep 2345
zumbruk 8000 7958 0 17:09 pts/2 00:00:00 sleep 34567
As you can see, the parameters passed to the "sleep" commands are shown, so you can tell which one is which from that (I just ran "sleep 12345&"
So something like;
ps -eaf | grep sleep | grep -v grep | awk "{print $9}"
Will give you a list of jobs...
999999999
12345
2345
34567
You can print the process IDs too with "awk '{print $2,$9}'", and so on.
Feel free to drop me an email if you want any more help.
And if anyone's selling a track prepped Golf GTi, I'd like to know about that, too.
Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff


