Who keeps removing that file?
Posted
by mgerdts
on Oracle Blogs
See other posts from Oracle Blogs
or by mgerdts
Published on Fri, 8 Nov 2013 15:25:28 +0000
Indexed on
2013/11/08
16:04 UTC
Read the original article
Hit count: 250
/Oracle
Over the years, I've had many times when some file gets removed and there's no obvious culprit. With dtrace, it is somewhat easy to figure out:
#! /usr/sbin/dtrace -wqs syscall::unlinkat:entry /cleanpath(copyinstr(arg1)) == "/dev/null"/ { stop(); printf("%s[%d] stopped before removing /dev/null\n", execname, pid); system("ptree %d; pstack %d", pid, pid); }
That script will stop the process trying to remove /dev/null before it does it. You can allow it to continue by restarting (unstopping?) the command with prun(1) or killing it with kill -9. If you want the command to continue automatically after getting the ptree and pstack output, you can add "; prun %d" and another pid argument to the system() call.
© Oracle Blogs or respective owner