So the problem I want to find a tidy solution for is that when I log into a server (I have some Solaris and RHEL instances about), I try to find out what applications are running:

$ ps -auxww | grep <thing I look for, usually Java>

And I get a nice list of processes, PIDs, extra details, and with the entire process name and parameters that executed with it. While this generally provides enough information for me to find out what is running, some servers are run differently. I might have a server that has multiple instances of an app server used for different purposes. Other processes are remnants of a hung process that I have mixed with non-frozen processes. I don't want to shut down all java instances because I can't find out which process needs killing.

The solution I'd like to provide is during my start-up scripts, I'd like to prepend or append to a process some text that lets me throw a short description in. Is there anything that might let me do this?

If what I'm asking sounds impossible/silly/completely-off-his-rocker, I am open to alternate solutions that give me some ability to accomplish the same thing. I'm open for ideas, but this one popped up as being doable.

2 Answers 2


Here is an example of gravvity's suggestion:

$ MARKER=snooze sleep 120&
$ ps ew | grep -o ".*[M]ARKER=snooze"
11741 pts/2    S      0:00 sleep 120 MARKER=snooze

The e option makes ps print the environment of the process. The -o option and the regex make grep chop off any of the environment after the part we're searching for, but I wouldn't bet on it always having results this clean (more of the environment might get printed). Putting part of the pattern in square brackets performs the function that people often use a grep -v for - to eliminate the grep itself from the results.


It sounds like you want to uniquely tag each process so that you can discover it easily. I actually heard of that being done at a large corp by their monitoring team - every app got a unique code that could be easily found with a ps and grep.

On java you can use -D to set any variable, so you could easily just add something like "-Dmonitoringid=". The process would ignore it, but you can easily grep for it.

Alternatively, you can split out your app servers to each run under an ID specific to the application being served. We currently run a large farm of J2EE app servers, with many apps on each box, however, each runs under it's own ID to split out ownership, access, controls, etc.

This also means finding any given app server on a host is as simple as: ps <whichever ps args you like best> | grep java | grep <uid> | grep -v grep

  • One can also use environment variables for this - they are not dependent on Java or anything. (The downside is that child processes inherit them.)
    – user1686
    Jan 21, 2010 at 20:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.