How to determine which process is creating a file?
Two files have suddenly appeared in my home directory, called "aa" and "err". They are empty. I'm wondering how they got there. I deleted the files and they are created again after some seconds.
Is there a way to monitor the home directory for the creation of files to find out where they came from?
I mention that lsof
couldn't help in this case (I got an empty result using lsof aa
)
macos file
add a comment |
Two files have suddenly appeared in my home directory, called "aa" and "err". They are empty. I'm wondering how they got there. I deleted the files and they are created again after some seconds.
Is there a way to monitor the home directory for the creation of files to find out where they came from?
I mention that lsof
couldn't help in this case (I got an empty result using lsof aa
)
macos file
add a comment |
Two files have suddenly appeared in my home directory, called "aa" and "err". They are empty. I'm wondering how they got there. I deleted the files and they are created again after some seconds.
Is there a way to monitor the home directory for the creation of files to find out where they came from?
I mention that lsof
couldn't help in this case (I got an empty result using lsof aa
)
macos file
Two files have suddenly appeared in my home directory, called "aa" and "err". They are empty. I'm wondering how they got there. I deleted the files and they are created again after some seconds.
Is there a way to monitor the home directory for the creation of files to find out where they came from?
I mention that lsof
couldn't help in this case (I got an empty result using lsof aa
)
macos file
macos file
edited 3 hours ago
bmike♦
156k46282606
156k46282606
asked 4 hours ago
Kwadz
13316
13316
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
fs_usage
is your tool for this.
The file system usage tool is ideal since it taps in to the real time file system events and dumps activity to a file or the screen. Since you know the exact path of the file, you can filter out all the thousands of irrelevant (to this case) filesystem changes and see what reads / writes to that file pretty quickly.
If your home directory is /Users/me
then you can filter for /Users/me/aa
mac:~ me$ sudo fs_usage | grep /Users/me/aa
09:35:21 stat64 /Users/me/aa 0.000033 touch
09:35:21 utimes /Users/me/aa 0.000104 touch
09:35:21 fsgetpath /Users/me/aa 0.000119 Finder
09:35:22 lstat64 /Users/me/aa 0.000039 fseventsd
09:35:22 fsgetpath /Users/me/aa 0.000027 mds
09:35:22 getattrlist /Users/me/aa 0.000064 mds
09:35:22 listxattr /Users/me/aa 0.000012 mds
09:35:22 getattrlist /Users/me/aa 0.000130 mds
09:35:22 getattrlist /Users/me/aa 0.000033 mds
09:35:22 open /Users/me/aa 0.000071 mdworker_sha
09:35:22 RdData[AT2] /Users/me/aa 0.000331 W mdworker_sha
09:35:22 getattrlist /Users/me/aa 0.000042 mds
09:35:24 lstat64 /Users/me/aa 0.000114 rm
09:35:24 access /Users/me/aa 0.000209 rm
09:35:24 unlink /Users/me/aa 0.000909 rm
09:35:25 lstat64 /Users/me/aa 0.000042 fseventsd
09:35:25 lstat64 /Users/me/aa 0.000006 rm
(note: I deleted a lot of white space above - the fs_usage command outputs a wide amount of empty space so you can't easily see the touch command on the far right if I copy/paste the exact output.)
Here I use the touch
command to create the file, append a string to it and then rm
it from the command line.
mac:~ me$ touch ~/aa
mac:~ me$ echo foo >> ~/aa
mac:~ me$ rm ~/aa
There will be tons of other apps that read, so you can filter on the stat64 and lstat74 operations if there are too many attribute reads and spotlight activity around the file once it's created.
- http://toddsnotes.blogspot.com/2014/02/use-fsusage-to-monitor-file-system.html
- https://developer.apple.com/library/archive/documentation/Performance/Conceptual/FileSystem/Articles/FileSystemCalls.html
The manual page for this command is quite dense (and not a "how-to") which is typical but better than no documentation from Apple on how to use it.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "118"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fapple.stackexchange.com%2fquestions%2f347040%2fhow-to-determine-which-process-is-creating-a-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
fs_usage
is your tool for this.
The file system usage tool is ideal since it taps in to the real time file system events and dumps activity to a file or the screen. Since you know the exact path of the file, you can filter out all the thousands of irrelevant (to this case) filesystem changes and see what reads / writes to that file pretty quickly.
If your home directory is /Users/me
then you can filter for /Users/me/aa
mac:~ me$ sudo fs_usage | grep /Users/me/aa
09:35:21 stat64 /Users/me/aa 0.000033 touch
09:35:21 utimes /Users/me/aa 0.000104 touch
09:35:21 fsgetpath /Users/me/aa 0.000119 Finder
09:35:22 lstat64 /Users/me/aa 0.000039 fseventsd
09:35:22 fsgetpath /Users/me/aa 0.000027 mds
09:35:22 getattrlist /Users/me/aa 0.000064 mds
09:35:22 listxattr /Users/me/aa 0.000012 mds
09:35:22 getattrlist /Users/me/aa 0.000130 mds
09:35:22 getattrlist /Users/me/aa 0.000033 mds
09:35:22 open /Users/me/aa 0.000071 mdworker_sha
09:35:22 RdData[AT2] /Users/me/aa 0.000331 W mdworker_sha
09:35:22 getattrlist /Users/me/aa 0.000042 mds
09:35:24 lstat64 /Users/me/aa 0.000114 rm
09:35:24 access /Users/me/aa 0.000209 rm
09:35:24 unlink /Users/me/aa 0.000909 rm
09:35:25 lstat64 /Users/me/aa 0.000042 fseventsd
09:35:25 lstat64 /Users/me/aa 0.000006 rm
(note: I deleted a lot of white space above - the fs_usage command outputs a wide amount of empty space so you can't easily see the touch command on the far right if I copy/paste the exact output.)
Here I use the touch
command to create the file, append a string to it and then rm
it from the command line.
mac:~ me$ touch ~/aa
mac:~ me$ echo foo >> ~/aa
mac:~ me$ rm ~/aa
There will be tons of other apps that read, so you can filter on the stat64 and lstat74 operations if there are too many attribute reads and spotlight activity around the file once it's created.
- http://toddsnotes.blogspot.com/2014/02/use-fsusage-to-monitor-file-system.html
- https://developer.apple.com/library/archive/documentation/Performance/Conceptual/FileSystem/Articles/FileSystemCalls.html
The manual page for this command is quite dense (and not a "how-to") which is typical but better than no documentation from Apple on how to use it.
add a comment |
fs_usage
is your tool for this.
The file system usage tool is ideal since it taps in to the real time file system events and dumps activity to a file or the screen. Since you know the exact path of the file, you can filter out all the thousands of irrelevant (to this case) filesystem changes and see what reads / writes to that file pretty quickly.
If your home directory is /Users/me
then you can filter for /Users/me/aa
mac:~ me$ sudo fs_usage | grep /Users/me/aa
09:35:21 stat64 /Users/me/aa 0.000033 touch
09:35:21 utimes /Users/me/aa 0.000104 touch
09:35:21 fsgetpath /Users/me/aa 0.000119 Finder
09:35:22 lstat64 /Users/me/aa 0.000039 fseventsd
09:35:22 fsgetpath /Users/me/aa 0.000027 mds
09:35:22 getattrlist /Users/me/aa 0.000064 mds
09:35:22 listxattr /Users/me/aa 0.000012 mds
09:35:22 getattrlist /Users/me/aa 0.000130 mds
09:35:22 getattrlist /Users/me/aa 0.000033 mds
09:35:22 open /Users/me/aa 0.000071 mdworker_sha
09:35:22 RdData[AT2] /Users/me/aa 0.000331 W mdworker_sha
09:35:22 getattrlist /Users/me/aa 0.000042 mds
09:35:24 lstat64 /Users/me/aa 0.000114 rm
09:35:24 access /Users/me/aa 0.000209 rm
09:35:24 unlink /Users/me/aa 0.000909 rm
09:35:25 lstat64 /Users/me/aa 0.000042 fseventsd
09:35:25 lstat64 /Users/me/aa 0.000006 rm
(note: I deleted a lot of white space above - the fs_usage command outputs a wide amount of empty space so you can't easily see the touch command on the far right if I copy/paste the exact output.)
Here I use the touch
command to create the file, append a string to it and then rm
it from the command line.
mac:~ me$ touch ~/aa
mac:~ me$ echo foo >> ~/aa
mac:~ me$ rm ~/aa
There will be tons of other apps that read, so you can filter on the stat64 and lstat74 operations if there are too many attribute reads and spotlight activity around the file once it's created.
- http://toddsnotes.blogspot.com/2014/02/use-fsusage-to-monitor-file-system.html
- https://developer.apple.com/library/archive/documentation/Performance/Conceptual/FileSystem/Articles/FileSystemCalls.html
The manual page for this command is quite dense (and not a "how-to") which is typical but better than no documentation from Apple on how to use it.
add a comment |
fs_usage
is your tool for this.
The file system usage tool is ideal since it taps in to the real time file system events and dumps activity to a file or the screen. Since you know the exact path of the file, you can filter out all the thousands of irrelevant (to this case) filesystem changes and see what reads / writes to that file pretty quickly.
If your home directory is /Users/me
then you can filter for /Users/me/aa
mac:~ me$ sudo fs_usage | grep /Users/me/aa
09:35:21 stat64 /Users/me/aa 0.000033 touch
09:35:21 utimes /Users/me/aa 0.000104 touch
09:35:21 fsgetpath /Users/me/aa 0.000119 Finder
09:35:22 lstat64 /Users/me/aa 0.000039 fseventsd
09:35:22 fsgetpath /Users/me/aa 0.000027 mds
09:35:22 getattrlist /Users/me/aa 0.000064 mds
09:35:22 listxattr /Users/me/aa 0.000012 mds
09:35:22 getattrlist /Users/me/aa 0.000130 mds
09:35:22 getattrlist /Users/me/aa 0.000033 mds
09:35:22 open /Users/me/aa 0.000071 mdworker_sha
09:35:22 RdData[AT2] /Users/me/aa 0.000331 W mdworker_sha
09:35:22 getattrlist /Users/me/aa 0.000042 mds
09:35:24 lstat64 /Users/me/aa 0.000114 rm
09:35:24 access /Users/me/aa 0.000209 rm
09:35:24 unlink /Users/me/aa 0.000909 rm
09:35:25 lstat64 /Users/me/aa 0.000042 fseventsd
09:35:25 lstat64 /Users/me/aa 0.000006 rm
(note: I deleted a lot of white space above - the fs_usage command outputs a wide amount of empty space so you can't easily see the touch command on the far right if I copy/paste the exact output.)
Here I use the touch
command to create the file, append a string to it and then rm
it from the command line.
mac:~ me$ touch ~/aa
mac:~ me$ echo foo >> ~/aa
mac:~ me$ rm ~/aa
There will be tons of other apps that read, so you can filter on the stat64 and lstat74 operations if there are too many attribute reads and spotlight activity around the file once it's created.
- http://toddsnotes.blogspot.com/2014/02/use-fsusage-to-monitor-file-system.html
- https://developer.apple.com/library/archive/documentation/Performance/Conceptual/FileSystem/Articles/FileSystemCalls.html
The manual page for this command is quite dense (and not a "how-to") which is typical but better than no documentation from Apple on how to use it.
fs_usage
is your tool for this.
The file system usage tool is ideal since it taps in to the real time file system events and dumps activity to a file or the screen. Since you know the exact path of the file, you can filter out all the thousands of irrelevant (to this case) filesystem changes and see what reads / writes to that file pretty quickly.
If your home directory is /Users/me
then you can filter for /Users/me/aa
mac:~ me$ sudo fs_usage | grep /Users/me/aa
09:35:21 stat64 /Users/me/aa 0.000033 touch
09:35:21 utimes /Users/me/aa 0.000104 touch
09:35:21 fsgetpath /Users/me/aa 0.000119 Finder
09:35:22 lstat64 /Users/me/aa 0.000039 fseventsd
09:35:22 fsgetpath /Users/me/aa 0.000027 mds
09:35:22 getattrlist /Users/me/aa 0.000064 mds
09:35:22 listxattr /Users/me/aa 0.000012 mds
09:35:22 getattrlist /Users/me/aa 0.000130 mds
09:35:22 getattrlist /Users/me/aa 0.000033 mds
09:35:22 open /Users/me/aa 0.000071 mdworker_sha
09:35:22 RdData[AT2] /Users/me/aa 0.000331 W mdworker_sha
09:35:22 getattrlist /Users/me/aa 0.000042 mds
09:35:24 lstat64 /Users/me/aa 0.000114 rm
09:35:24 access /Users/me/aa 0.000209 rm
09:35:24 unlink /Users/me/aa 0.000909 rm
09:35:25 lstat64 /Users/me/aa 0.000042 fseventsd
09:35:25 lstat64 /Users/me/aa 0.000006 rm
(note: I deleted a lot of white space above - the fs_usage command outputs a wide amount of empty space so you can't easily see the touch command on the far right if I copy/paste the exact output.)
Here I use the touch
command to create the file, append a string to it and then rm
it from the command line.
mac:~ me$ touch ~/aa
mac:~ me$ echo foo >> ~/aa
mac:~ me$ rm ~/aa
There will be tons of other apps that read, so you can filter on the stat64 and lstat74 operations if there are too many attribute reads and spotlight activity around the file once it's created.
- http://toddsnotes.blogspot.com/2014/02/use-fsusage-to-monitor-file-system.html
- https://developer.apple.com/library/archive/documentation/Performance/Conceptual/FileSystem/Articles/FileSystemCalls.html
The manual page for this command is quite dense (and not a "how-to") which is typical but better than no documentation from Apple on how to use it.
edited 3 hours ago
answered 3 hours ago
bmike♦
156k46282606
156k46282606
add a comment |
add a comment |
Thanks for contributing an answer to Ask Different!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fapple.stackexchange.com%2fquestions%2f347040%2fhow-to-determine-which-process-is-creating-a-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown