troubleshooting Question

Check if script is still running in bash

Avatar of enthuguy
enthuguyFlag for Australia asked on
JavaShell ScriptingLinuxUnix OS
5 Comments1 Solution160 ViewsLast Modified:
Hi Friends,

Have a script which invoke same shell script with different argument in background (usually runs couple of hours)

In above scenarios,
1. would like to check if all the above script execution has finished or not
2. In a loop with sleep/interval?
3. Once all finished, call a function and exit

I dont want to use sleep which increases the overall time for some reason in the script. Instead would like to use grep and check in a loop. pls help what is the best way to achieve this

ps -ef | grep  backgroundDummyProc | grep -v grep
if [ $? -eq 1 ]
    echo "Not running"
      echo "running"

Thanks in advance
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros