bash - Linux shell - How to find for all running process if the file has been removed -
I would like to identify if there is a process for which the file (related process) does not exist.
I have so far:
# [! -f / my / file]; Compared to echo "not present"; Fi to understand whether a file exists
Now I need a list of processes, remove files that generate process, remove arguments And to verify if the file exists or not ... but I am struggling to do this, besides this, I have to be careful as the process: / bin / sh / my / skcript.sh / usr / bin / python / my / python_file
(For this second case I partially Sector can identify if script.sh or python_file "lsof | grep deleted" has been deleted using)
Did you know that a great way to do this?
Then in the form of root, You should list all deleted files to it: lsof | Grep '(deleted)'
After that, you can shorten the list by matching the filename to the executable name (if it matches, it's potentially being deleted executable ).
I matches all executables used to run the script (Rabbi, Perl, etc.). Even better, I'll filter the executor who does not manually verify every remaining false positive.
Proof
Compiling this short program:
main (int argc, char * argv []) {for (;;) }} Return 0; } $ Gcc useless.c -o idle run it
$ / False then removing it (in other terminal):
$ rm idle root shows Is running LSO as:
useless 738 dioo txt REG 8,4 7955 40685 / home / diyō / useless (destroyed) < / Html>
Comments
Post a Comment