reliable replacement for "ps -ef"

On linux redhat 5 I checked the command ps -ef in a loop and found out that it is not reliable.
checked this way:
while [ `ps -ef |grep tnslsnr | grep -v grep | wc -l` -eq 1 ]; do printf . ; done
after about of 2 minutes the loop finished since it didn't find the process.

looking for something more trusted I found the command pgrep
checked this way:
while [ `pgrep tnslsnr 1>/dev/null; echo $?` -ne 1 ]; do printf . ; done
and it is still running in a loop .... ;)
and no need to use awk or grep -v

here are some commands and the behavior of pgrep:
# pgrep smon
# pgrep -f smon
# pgrep -fl smon
2396 ora_smon_orcl
2533 ora_smon_mydb
# pgrep -fl ora_smon_orcl
2396 ora_smon_orcl
# echo $?
# pgrep not_exist_process
# echo $?

There are some more parameters, check: man pgrep


Popular posts from this blog

Fixing & Registering ORACLE_HOMES in Central Inventory

Export in Pl/Sql via DBMS_DATAPUMP

Oracle 18c - New Features for Active Data Guard