Several days ago I ran multiple instances of an application (Matlab) on a remote server (I'm not root). Each instance redirects output to a log file.

Today I want to kill a process that is redirecting output to a particular log file. I know the name of that log file, and the PID of all running processes of that application. But I don't know which PID corresponds to that log file.

My question is how to find the PID that is writing to that log file? Or at least get the command history of several days ago; so that I can estimate the time I ran that command, then compare it with the running time of the current PIDs, and find out the closest match?

Note: I tried the command history but it only shows the history of today when I'm still logged in. What I often do is to login to the server, start a process, logout, and login again the next days to view the results.

有帮助吗?

解决方案

My question is how to find the PID that is writing to that log file

fuser - identify processes using files or sockets

So, do this:

fuser filename

其他提示

If you started the command like this:

command > logfile.1

Then you can run ps aux | grep logfile.1 to get the process.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top