I run this command "httpd -d ./inst2 -k start" to boot Apache Server, and I can see this command line through "ps -ef | grep httpd". My question is if i don't know the absolute path, is there a way to get the absolute path of "./inst2"?
Thanks
You can try to GUESS what the absolute path is by examining the pseudo symbolic link /proc/PID/cwd
where PID
can be determined from the ps
output: ls -l /proc/PID/cwd
. But please note that it is just the current working directory and your path may be resolved against any other directory, so it is just a guess.
Another option, if your program opens some files using this relative path and in fact you need to determine the full path of such files, you can enumerate files currently open by some process using /proc/PID/fd
pseudo directory: ls -l /proc/PID/fd
. But, of course, the file can already be closed by the time of executing ls
. And I don't know what it will show if the open file was moved to some other place.