Quote:
Originally Posted by druuna
Hi,
You are aware that top (tries to) read /etc/toprc and ~/.toprc?
If the parameters you want to give to top are always the same you could consider creating a ~/.toprc (start top, set all the options and press W).
I'm not 100% sure, but I don't think you can feed top any options once it is up and running.
Hope this helps.
|
Actually, if you can't, it will be a kinda useless utility. That's why I believe it can be feeded. As there is probably a misunderstanding about what I want, here is the code:
Code:
#!/bin/bash
NRCORES=`mpstat | grep CPU | head -n1 | awk '{print $6}' | tr -d "(" | bc`
PIDOFJAVA=`pidof java`
echo $PIDOFJAVA
echo $NRCORES
echo "Now trying to do the shit..."
exec 6<&0
exec < input
`top -p $PIDOFJAVA`
read a1
echo $a1
exec 0<&6 6<&-
the input file is in the same directory and contains only
1[newline feed]
If you reproduce the thingy in normal terminal:
waits for user input, and if you press one (1), it shows the cpu/memory utilization on the java process on different cores.
I want to be able to do that programatically, so user input is not required