简体   繁体   中英

How to find bash script name from pid?

I'm using SUNOS. First I run that command to find top cpu using proccesses.

ps -eo pmem,pcpu,pid,args | sort -rnk 2

Then its the output

0.0  4.2 19105 bash

19105 is 'process id' and, 'bash' is args.

I just saw bash in args section. How can I find which bash script is working? I tried pwdx command but it just shows me working directory of script. It doesnt show me that which script is working with this pid.

I wish someone help me.

If you have the PID of any process, you can use ps -ef|grep pid to check the running process and its parent-pid (column 3).

If you want to know more, check ps- ef|grep parent-pid to find from where the child process is spawned.

You can use this to even find the user/terminal who has executed the process.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM