-5
#Create & update pid file
/usr/ucb/ps -axuwww | grep java | grep "SmartFileConvertor $instance" | grep -v grep | nawk '{ print $2 }' > ${pidFile}
2

ps -axuwww :
axu : BSD syntax to list all the processes in the system
www : maximum width

Here is the full command which is run from left to right:
/usr/ucb/ps -axuwww | grep java : output only lines containing "java"
..| grep "SmartFileConvertor $instance" : output only lines containing "SmartFileConvertor" with some instance value set as an environment variable
..| grep -v grep : output only lines that don't include "grep"
..| nawk '{ print $2 }' : output the second column which is the pid
..> ${pidFile} : redirect the output to the file with the name inside the pidFile environment variable

When you want to know the parameters of a command / program, a man page is usually available with the man command such as man ps and man grep.

  • 5
    Suppose there is a Jennifer A. Vasquez whose username is javasquez. Her processes will be picked up by grep java, as will any process called java or even javac. grep will find matches anywhere in the line, not just from a single column – Fox Mar 17 '17 at 8:02

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.