On Fri, Apr 26, 2002 at 07:55:19AM -0700, Christopher Keller wrote: > On Thu, 2002-04-25 at 16:56, Michal Jaegermann wrote: > > (and you still have no idea in > > which order processes will be listed). > > > > Actually, I do. The ps command lists the processes in numerical order by > PID. By definition, X will have always been started before the renice. So? First of all you are actually not interested in a process id of that grep (or awk, or whatever). How you can assure that something started later will have a higher pid? The answer is "no way". > So that will work every time...guaranteed. No, you are playing a crapshot. It has pretty good chances to work if you have done that rather soon after you started your machine (and if do not have a big crowd of users then this helps as well). But in general, especially if you are restarting a server later, all bets are off. A saving grace in this particular case is that a failure does not have dire consequences. In an absence of 'pidof' an old trick to do things of that sort looks like that ps ax | awk '/[X] /{print $1}' Think for a moment why it works. :-) There are some variations, of course, and you have have to be careful not match too much. ps ax | awk '/\/[X] /{print $1}' could be better. As an exercise redo that filtering only with 'sed' (and then you can pick your regex delimiter :-). On the top of it you may have really more than one X server going with different displays (I often do on some machines). In such situations you have to loop through all pid's or you will be just chaning priorities on some random one and who knows which is that. > However, the pidof is a much better solution. Completely unaware it > existed. Thanks. It is in 'root' path so it is normally "invisible" from non-root accounts. Michal