Check whether a file is opened or not
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have a folder, inside of which there are a lot of files. I was looking for a way to check whether any file inside that folder has been opened or not. If it is open, I need to get notified. I know this can be done using inotify-wait but have not been able to do so.
Here is my script
MONITORDIR="/home/aniketshivamtiwari/Downloads/Projects"
inotifywait -m -r -e create --format '%w%f' "$MONITORDIR" | while read NEWFILE
do
echo "File $NEWFILE has been opened"
done
shell-script shell inotify
add a comment |Â
up vote
0
down vote
favorite
I have a folder, inside of which there are a lot of files. I was looking for a way to check whether any file inside that folder has been opened or not. If it is open, I need to get notified. I know this can be done using inotify-wait but have not been able to do so.
Here is my script
MONITORDIR="/home/aniketshivamtiwari/Downloads/Projects"
inotifywait -m -r -e create --format '%w%f' "$MONITORDIR" | while read NEWFILE
do
echo "File $NEWFILE has been opened"
done
shell-script shell inotify
Closely related: Using inotify to monitor a directory but not working 100%
â Michael Homer
Oct 15 '17 at 6:40
1
Why do you usecreate
and notopen
if what you want is to monitor wheter files inside the directory are opened? Couldn't you use something like this instead:inotifywait -m -q -e open --format '%w%f' $MONITORDIR/*
?
â Rastapopoulos
Oct 15 '17 at 8:26
@Rastapopoulos - Your solution worked
â Aniket Shivam Tiwari
Oct 15 '17 at 13:49
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a folder, inside of which there are a lot of files. I was looking for a way to check whether any file inside that folder has been opened or not. If it is open, I need to get notified. I know this can be done using inotify-wait but have not been able to do so.
Here is my script
MONITORDIR="/home/aniketshivamtiwari/Downloads/Projects"
inotifywait -m -r -e create --format '%w%f' "$MONITORDIR" | while read NEWFILE
do
echo "File $NEWFILE has been opened"
done
shell-script shell inotify
I have a folder, inside of which there are a lot of files. I was looking for a way to check whether any file inside that folder has been opened or not. If it is open, I need to get notified. I know this can be done using inotify-wait but have not been able to do so.
Here is my script
MONITORDIR="/home/aniketshivamtiwari/Downloads/Projects"
inotifywait -m -r -e create --format '%w%f' "$MONITORDIR" | while read NEWFILE
do
echo "File $NEWFILE has been opened"
done
shell-script shell inotify
edited Oct 15 '17 at 6:42
Anthon
58.6k1796159
58.6k1796159
asked Oct 15 '17 at 6:31
Aniket Shivam Tiwari
1113
1113
Closely related: Using inotify to monitor a directory but not working 100%
â Michael Homer
Oct 15 '17 at 6:40
1
Why do you usecreate
and notopen
if what you want is to monitor wheter files inside the directory are opened? Couldn't you use something like this instead:inotifywait -m -q -e open --format '%w%f' $MONITORDIR/*
?
â Rastapopoulos
Oct 15 '17 at 8:26
@Rastapopoulos - Your solution worked
â Aniket Shivam Tiwari
Oct 15 '17 at 13:49
add a comment |Â
Closely related: Using inotify to monitor a directory but not working 100%
â Michael Homer
Oct 15 '17 at 6:40
1
Why do you usecreate
and notopen
if what you want is to monitor wheter files inside the directory are opened? Couldn't you use something like this instead:inotifywait -m -q -e open --format '%w%f' $MONITORDIR/*
?
â Rastapopoulos
Oct 15 '17 at 8:26
@Rastapopoulos - Your solution worked
â Aniket Shivam Tiwari
Oct 15 '17 at 13:49
Closely related: Using inotify to monitor a directory but not working 100%
â Michael Homer
Oct 15 '17 at 6:40
Closely related: Using inotify to monitor a directory but not working 100%
â Michael Homer
Oct 15 '17 at 6:40
1
1
Why do you use
create
and not open
if what you want is to monitor wheter files inside the directory are opened? Couldn't you use something like this instead: inotifywait -m -q -e open --format '%w%f' $MONITORDIR/*
?â Rastapopoulos
Oct 15 '17 at 8:26
Why do you use
create
and not open
if what you want is to monitor wheter files inside the directory are opened? Couldn't you use something like this instead: inotifywait -m -q -e open --format '%w%f' $MONITORDIR/*
?â Rastapopoulos
Oct 15 '17 at 8:26
@Rastapopoulos - Your solution worked
â Aniket Shivam Tiwari
Oct 15 '17 at 13:49
@Rastapopoulos - Your solution worked
â Aniket Shivam Tiwari
Oct 15 '17 at 13:49
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
Here is the solution
First install sudo apt-get install inotify-tools
MONITORDIR="path/to/the/folder"
inotifywait -m -q -e open --format '%w%f' $MONITORDIR/* | while read NEWFILE
do
echo "File $NEWFILE has been open"
done
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Here is the solution
First install sudo apt-get install inotify-tools
MONITORDIR="path/to/the/folder"
inotifywait -m -q -e open --format '%w%f' $MONITORDIR/* | while read NEWFILE
do
echo "File $NEWFILE has been open"
done
add a comment |Â
up vote
1
down vote
Here is the solution
First install sudo apt-get install inotify-tools
MONITORDIR="path/to/the/folder"
inotifywait -m -q -e open --format '%w%f' $MONITORDIR/* | while read NEWFILE
do
echo "File $NEWFILE has been open"
done
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Here is the solution
First install sudo apt-get install inotify-tools
MONITORDIR="path/to/the/folder"
inotifywait -m -q -e open --format '%w%f' $MONITORDIR/* | while read NEWFILE
do
echo "File $NEWFILE has been open"
done
Here is the solution
First install sudo apt-get install inotify-tools
MONITORDIR="path/to/the/folder"
inotifywait -m -q -e open --format '%w%f' $MONITORDIR/* | while read NEWFILE
do
echo "File $NEWFILE has been open"
done
edited Oct 15 '17 at 16:07
answered Oct 15 '17 at 13:49
Aniket Shivam Tiwari
1113
1113
add a comment |Â
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f398205%2fcheck-whether-a-file-is-opened-or-not%23new-answer', 'question_page');
);
Post as a guest
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
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
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
Closely related: Using inotify to monitor a directory but not working 100%
â Michael Homer
Oct 15 '17 at 6:40
1
Why do you use
create
and notopen
if what you want is to monitor wheter files inside the directory are opened? Couldn't you use something like this instead:inotifywait -m -q -e open --format '%w%f' $MONITORDIR/*
?â Rastapopoulos
Oct 15 '17 at 8:26
@Rastapopoulos - Your solution worked
â Aniket Shivam Tiwari
Oct 15 '17 at 13:49