Shell Script Produces Several Child Processes

(Doc ID 2019853.1)

Last updated on JANUARY 02, 2016

Applies to:

Solaris SPARC Operating System - Version 8 2/04 U8 and later
Information in this document applies to any platform.


 A shell script may try to verify that it is the only copy running by doing something similar to "ps -ef | grep script | grep -v grep | wc -l" and expecting the value to be 1

An example would be:


Note the shell can be /bin/sh or /bin/bash or other shell, they should all work similarly


$ cat

working_num=`ps -ef |grep |grep -v grep|wc -l`
if test $working_num -gt 1
echo "Another script is still working..."
exit 1




 N/A or anything that changes the timing


Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms