Problem with inotify-wait as daemon
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have been running inotify-wait on my ftp server in byobu to monitor a folder, move data, and send email notifications for a few months without problems. Since I started this I have added 3 more folders that I monitor and I would like to start running inotify-wait as a daemon instead of in byobu sessions. I modified my script to be easier to only require a single variable to be changed and to run as a daemon. Unfortunately it now does nothing. I was hoping someone with some experience could take a look and tell me where Ive gone wrong.
#!/usr/bin/env bash
user=testuser
dir=/ftp/"$user"/upload/
log=/ftp/"$user"/log/"$user.log"
archive=/ftp/"$user"/archive/
target=/ftp/FTPDATA/"$user"/
inotifywait -q
-d "$dir"
-o "$log"
-e close_write --format %f . | while IFS= read -r file; do
cp -p "$file" "$target"
/scripts/"$user-notify.sh"
mv "$file" "$archive""$(date +%F-%T)"
done
I am guessing the problem is with the -d "$dir"
but this is only my second time working with inotify-wait. Any help would be very much appreciated.
bash scripting inotify
add a comment |
I have been running inotify-wait on my ftp server in byobu to monitor a folder, move data, and send email notifications for a few months without problems. Since I started this I have added 3 more folders that I monitor and I would like to start running inotify-wait as a daemon instead of in byobu sessions. I modified my script to be easier to only require a single variable to be changed and to run as a daemon. Unfortunately it now does nothing. I was hoping someone with some experience could take a look and tell me where Ive gone wrong.
#!/usr/bin/env bash
user=testuser
dir=/ftp/"$user"/upload/
log=/ftp/"$user"/log/"$user.log"
archive=/ftp/"$user"/archive/
target=/ftp/FTPDATA/"$user"/
inotifywait -q
-d "$dir"
-o "$log"
-e close_write --format %f . | while IFS= read -r file; do
cp -p "$file" "$target"
/scripts/"$user-notify.sh"
mv "$file" "$archive""$(date +%F-%T)"
done
I am guessing the problem is with the -d "$dir"
but this is only my second time working with inotify-wait. Any help would be very much appreciated.
bash scripting inotify
"Does nothing" is a bit difficult to debug. Have you triedset -o errexit
? Have you tried printing a string when you enter the loop? Have you triedtouch
ing a file in the directory and seeing if the loop progresses? How are you running this as a daemon? Are you sureinotifywait
is on thePATH
in the context you're running it?
– l0b0
Jul 21 '15 at 16:49
I think you are correct that it the -d does not accept the "$dir" like the -m does in my previous script. I have been using touch to create files in the $dir and inotifywait does not appear to recognize the change.
– rfinterference
Jul 21 '15 at 17:29
add a comment |
I have been running inotify-wait on my ftp server in byobu to monitor a folder, move data, and send email notifications for a few months without problems. Since I started this I have added 3 more folders that I monitor and I would like to start running inotify-wait as a daemon instead of in byobu sessions. I modified my script to be easier to only require a single variable to be changed and to run as a daemon. Unfortunately it now does nothing. I was hoping someone with some experience could take a look and tell me where Ive gone wrong.
#!/usr/bin/env bash
user=testuser
dir=/ftp/"$user"/upload/
log=/ftp/"$user"/log/"$user.log"
archive=/ftp/"$user"/archive/
target=/ftp/FTPDATA/"$user"/
inotifywait -q
-d "$dir"
-o "$log"
-e close_write --format %f . | while IFS= read -r file; do
cp -p "$file" "$target"
/scripts/"$user-notify.sh"
mv "$file" "$archive""$(date +%F-%T)"
done
I am guessing the problem is with the -d "$dir"
but this is only my second time working with inotify-wait. Any help would be very much appreciated.
bash scripting inotify
I have been running inotify-wait on my ftp server in byobu to monitor a folder, move data, and send email notifications for a few months without problems. Since I started this I have added 3 more folders that I monitor and I would like to start running inotify-wait as a daemon instead of in byobu sessions. I modified my script to be easier to only require a single variable to be changed and to run as a daemon. Unfortunately it now does nothing. I was hoping someone with some experience could take a look and tell me where Ive gone wrong.
#!/usr/bin/env bash
user=testuser
dir=/ftp/"$user"/upload/
log=/ftp/"$user"/log/"$user.log"
archive=/ftp/"$user"/archive/
target=/ftp/FTPDATA/"$user"/
inotifywait -q
-d "$dir"
-o "$log"
-e close_write --format %f . | while IFS= read -r file; do
cp -p "$file" "$target"
/scripts/"$user-notify.sh"
mv "$file" "$archive""$(date +%F-%T)"
done
I am guessing the problem is with the -d "$dir"
but this is only my second time working with inotify-wait. Any help would be very much appreciated.
bash scripting inotify
bash scripting inotify
edited Jul 21 '15 at 16:46
l0b0
28.8k20122249
28.8k20122249
asked Jul 21 '15 at 15:14
rfinterferencerfinterference
1
1
"Does nothing" is a bit difficult to debug. Have you triedset -o errexit
? Have you tried printing a string when you enter the loop? Have you triedtouch
ing a file in the directory and seeing if the loop progresses? How are you running this as a daemon? Are you sureinotifywait
is on thePATH
in the context you're running it?
– l0b0
Jul 21 '15 at 16:49
I think you are correct that it the -d does not accept the "$dir" like the -m does in my previous script. I have been using touch to create files in the $dir and inotifywait does not appear to recognize the change.
– rfinterference
Jul 21 '15 at 17:29
add a comment |
"Does nothing" is a bit difficult to debug. Have you triedset -o errexit
? Have you tried printing a string when you enter the loop? Have you triedtouch
ing a file in the directory and seeing if the loop progresses? How are you running this as a daemon? Are you sureinotifywait
is on thePATH
in the context you're running it?
– l0b0
Jul 21 '15 at 16:49
I think you are correct that it the -d does not accept the "$dir" like the -m does in my previous script. I have been using touch to create files in the $dir and inotifywait does not appear to recognize the change.
– rfinterference
Jul 21 '15 at 17:29
"Does nothing" is a bit difficult to debug. Have you tried
set -o errexit
? Have you tried printing a string when you enter the loop? Have you tried touch
ing a file in the directory and seeing if the loop progresses? How are you running this as a daemon? Are you sure inotifywait
is on the PATH
in the context you're running it?– l0b0
Jul 21 '15 at 16:49
"Does nothing" is a bit difficult to debug. Have you tried
set -o errexit
? Have you tried printing a string when you enter the loop? Have you tried touch
ing a file in the directory and seeing if the loop progresses? How are you running this as a daemon? Are you sure inotifywait
is on the PATH
in the context you're running it?– l0b0
Jul 21 '15 at 16:49
I think you are correct that it the -d does not accept the "$dir" like the -m does in my previous script. I have been using touch to create files in the $dir and inotifywait does not appear to recognize the change.
– rfinterference
Jul 21 '15 at 17:29
I think you are correct that it the -d does not accept the "$dir" like the -m does in my previous script. I have been using touch to create files in the $dir and inotifywait does not appear to recognize the change.
– rfinterference
Jul 21 '15 at 17:29
add a comment |
1 Answer
1
active
oldest
votes
Which version of inotifywait
are you using? According to this man
page -d
specifies that you want to run it as a daemon, but it doesn't take an argument value ("$dir"
). Also with -o "$log"
it will be saving output to the log file and not sending it to standard output. Make sure you have a working inotifywait
command before continuing with the script - ideally add a test which watches some files in a temporary directory (or re-implement in a better language like Java, Python or Ruby).
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
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%2funix.stackexchange.com%2fquestions%2f217399%2fproblem-with-inotify-wait-as-daemon%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
Which version of inotifywait
are you using? According to this man
page -d
specifies that you want to run it as a daemon, but it doesn't take an argument value ("$dir"
). Also with -o "$log"
it will be saving output to the log file and not sending it to standard output. Make sure you have a working inotifywait
command before continuing with the script - ideally add a test which watches some files in a temporary directory (or re-implement in a better language like Java, Python or Ruby).
add a comment |
Which version of inotifywait
are you using? According to this man
page -d
specifies that you want to run it as a daemon, but it doesn't take an argument value ("$dir"
). Also with -o "$log"
it will be saving output to the log file and not sending it to standard output. Make sure you have a working inotifywait
command before continuing with the script - ideally add a test which watches some files in a temporary directory (or re-implement in a better language like Java, Python or Ruby).
add a comment |
Which version of inotifywait
are you using? According to this man
page -d
specifies that you want to run it as a daemon, but it doesn't take an argument value ("$dir"
). Also with -o "$log"
it will be saving output to the log file and not sending it to standard output. Make sure you have a working inotifywait
command before continuing with the script - ideally add a test which watches some files in a temporary directory (or re-implement in a better language like Java, Python or Ruby).
Which version of inotifywait
are you using? According to this man
page -d
specifies that you want to run it as a daemon, but it doesn't take an argument value ("$dir"
). Also with -o "$log"
it will be saving output to the log file and not sending it to standard output. Make sure you have a working inotifywait
command before continuing with the script - ideally add a test which watches some files in a temporary directory (or re-implement in a better language like Java, Python or Ruby).
answered Jul 21 '15 at 16:52
l0b0l0b0
28.8k20122249
28.8k20122249
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- 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%2funix.stackexchange.com%2fquestions%2f217399%2fproblem-with-inotify-wait-as-daemon%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
"Does nothing" is a bit difficult to debug. Have you tried
set -o errexit
? Have you tried printing a string when you enter the loop? Have you triedtouch
ing a file in the directory and seeing if the loop progresses? How are you running this as a daemon? Are you sureinotifywait
is on thePATH
in the context you're running it?– l0b0
Jul 21 '15 at 16:49
I think you are correct that it the -d does not accept the "$dir" like the -m does in my previous script. I have been using touch to create files in the $dir and inotifywait does not appear to recognize the change.
– rfinterference
Jul 21 '15 at 17:29