Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 6791  / 3 Years ago, thu, may 20, 2021, 1:10:16

I have a number of ruby processes running:



ps -A | grep ruby 
3518 ? 00:00:12 ruby
10316 ? 00:00:00 ruby
22400 pts/5 00:00:45 ruby
23332 ? 00:00:07 ruby


I get the pid above, but I want to know WHERE these processes are in the filesystem. In other words, where they were executed.



Why do I want to know? I have a daemon running in a byobu screen and I want to know where it was executed from.



byobu new -s daemon
ls -l
-rwxrwxr-x 1 someuser someuser 83 Jul 2 11:13 db_service.sh
cat db_service.sh
#!/bin/sh
RAILS_ENV=production bundle exec ruby lib/daemons/db_service_ctl start
./script/db_service.sh


So as you can see from the above bash commands, a daemon was spawned (ruby on rails daemon) from the db_service.sh shell script. So where in the filesystem was it spawned from? Can ps help me here or is there a better program in linux to find out the desired information? I am not looking for the path of the ruby installation, but rather the path at which a ruby instance was executed


More From » bash

 Answers
2

So you got the process id, you can then look around the /proc/ virtual file system. Everything is there. For e.g.




  • /proc/23124/cwd - the current directory of process 23124

  • /proc/23124/cmdline - the full command line of the process.


[#30380] Saturday, May 22, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rcraftemur

Total Points: 118
Total Questions: 119
Total Answers: 144

Location: Turks and Caicos Islands
Member since Sun, Mar 7, 2021
3 Years ago
;