Problem with inotify-wait as daemon

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








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.










share|improve this question
























  • "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 touching 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

















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.










share|improve this question
























  • "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 touching 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













0












0








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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 tried set -o errexit? Have you tried printing a string when you enter the loop? Have you tried touching 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

















  • "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 touching 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
















"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 touching 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 touching 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










1 Answer
1






active

oldest

votes


















0














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).






share|improve this answer























    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
    );



    );













    draft saved

    draft discarded


















    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









    0














    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).






    share|improve this answer



























      0














      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).






      share|improve this answer

























        0












        0








        0







        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).






        share|improve this answer













        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).







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jul 21 '15 at 16:52









        l0b0l0b0

        28.8k20122249




        28.8k20122249



























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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






            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?