2016年12月5日 星期一

[Linux 常見問題] How to get child process from parent process


Source From Here
Question
Is it possible to get the child process id from parent process id in shell script?

How-To
You can leverage command pgrep. For example:
// List process tree
# ps auxf
...


// List process(s) with parent pid=3253
# pgrep -P 3253
3254
3545


// List process(s) with parent pid=3254
# pgrep -P 3254

// List process(s) with parent pid=3254
# pgrep -P 3545
3565
3712
3719
3736
 


沒有留言:

張貼留言

[Linux 常見問題] sudo: Sorry, you must have a tty to run sudo Error on a Linux and Unix

Source From  Here   Preface   I‘m trying to run the following command:  #   ssh  user@box.example.com  sudo command1 /path/to/file But, a...