I need to check if a process complete or not by shell script (linux and windows). What I know is the process ID. Once the process complete, the shell will call other commands. Could someone tell me how to write the shell?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
On Linux you can use ps -p $PID to check the process, so you could write a while loop that checks e.g.
ps -p $PID | wc -l(this counts the lines, if the process is finished the output will result in less lines). you could break the while loop under this condition and then all the other code would be executed. I cannot write a snippet, because I do not have an access to a shell at the moment.