rsync doesn't run when from a bash script












0















I have wakeup script that runs when the system wakes up (Arch linux)



$ cat /usr/lib/pm-utils/sleep.d/example

#!/bin/bash
case "$1" in
resume)
echo "hey I just got resumed!"
/usr/bin/bash /home/user/bin/wakeup_script
esac


my wakeup_script



$ cat bin/wakeup_script

#!/bin/bash
/usr/bin/touch /home/user/testwake.txt
/usr/bin/rsync -vaz user@xx.xx.xx.xx:/home/user/downloads/test.txt /mnt/data/
/home/user/bin/mnt d


you can see that the script "wakeup_script" contains three bash script. When the system wakes up, the first and third script runs very well but rsync never worked, I tried scp, it doesn't work again! what's wrong here?



when I execute the same "wakeup_script" in a shell, the rsync does work but it doesn't get executed when the system wakes up!!



$ /usr/bin/bash /home/user/bin/wakeup_script









share|improve this question


















  • 2





    Does the rsync command rely on an SSH identity from your user's ~/.ssh? when run by root (from pm-utils) it will be looking in /root/.ssh instead

    – steeldriver
    Mar 17 at 12:35











  • Maybe network is not available yet? Try to redirect the output of your script to a file to investigate what goes wrong. /usr/bin/bash /home/user/bin/wakeup_script &> /tmp/wakeup.log

    – Thomas
    Mar 17 at 12:36











  • yes, it requires SSH key. How can I resolve this?

    – kuruvi
    Mar 17 at 14:20
















0















I have wakeup script that runs when the system wakes up (Arch linux)



$ cat /usr/lib/pm-utils/sleep.d/example

#!/bin/bash
case "$1" in
resume)
echo "hey I just got resumed!"
/usr/bin/bash /home/user/bin/wakeup_script
esac


my wakeup_script



$ cat bin/wakeup_script

#!/bin/bash
/usr/bin/touch /home/user/testwake.txt
/usr/bin/rsync -vaz user@xx.xx.xx.xx:/home/user/downloads/test.txt /mnt/data/
/home/user/bin/mnt d


you can see that the script "wakeup_script" contains three bash script. When the system wakes up, the first and third script runs very well but rsync never worked, I tried scp, it doesn't work again! what's wrong here?



when I execute the same "wakeup_script" in a shell, the rsync does work but it doesn't get executed when the system wakes up!!



$ /usr/bin/bash /home/user/bin/wakeup_script









share|improve this question


















  • 2





    Does the rsync command rely on an SSH identity from your user's ~/.ssh? when run by root (from pm-utils) it will be looking in /root/.ssh instead

    – steeldriver
    Mar 17 at 12:35











  • Maybe network is not available yet? Try to redirect the output of your script to a file to investigate what goes wrong. /usr/bin/bash /home/user/bin/wakeup_script &> /tmp/wakeup.log

    – Thomas
    Mar 17 at 12:36











  • yes, it requires SSH key. How can I resolve this?

    – kuruvi
    Mar 17 at 14:20














0












0








0








I have wakeup script that runs when the system wakes up (Arch linux)



$ cat /usr/lib/pm-utils/sleep.d/example

#!/bin/bash
case "$1" in
resume)
echo "hey I just got resumed!"
/usr/bin/bash /home/user/bin/wakeup_script
esac


my wakeup_script



$ cat bin/wakeup_script

#!/bin/bash
/usr/bin/touch /home/user/testwake.txt
/usr/bin/rsync -vaz user@xx.xx.xx.xx:/home/user/downloads/test.txt /mnt/data/
/home/user/bin/mnt d


you can see that the script "wakeup_script" contains three bash script. When the system wakes up, the first and third script runs very well but rsync never worked, I tried scp, it doesn't work again! what's wrong here?



when I execute the same "wakeup_script" in a shell, the rsync does work but it doesn't get executed when the system wakes up!!



$ /usr/bin/bash /home/user/bin/wakeup_script









share|improve this question














I have wakeup script that runs when the system wakes up (Arch linux)



$ cat /usr/lib/pm-utils/sleep.d/example

#!/bin/bash
case "$1" in
resume)
echo "hey I just got resumed!"
/usr/bin/bash /home/user/bin/wakeup_script
esac


my wakeup_script



$ cat bin/wakeup_script

#!/bin/bash
/usr/bin/touch /home/user/testwake.txt
/usr/bin/rsync -vaz user@xx.xx.xx.xx:/home/user/downloads/test.txt /mnt/data/
/home/user/bin/mnt d


you can see that the script "wakeup_script" contains three bash script. When the system wakes up, the first and third script runs very well but rsync never worked, I tried scp, it doesn't work again! what's wrong here?



when I execute the same "wakeup_script" in a shell, the rsync does work but it doesn't get executed when the system wakes up!!



$ /usr/bin/bash /home/user/bin/wakeup_script






command-line bash rsync






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 17 at 12:29









kuruvikuruvi

1011




1011








  • 2





    Does the rsync command rely on an SSH identity from your user's ~/.ssh? when run by root (from pm-utils) it will be looking in /root/.ssh instead

    – steeldriver
    Mar 17 at 12:35











  • Maybe network is not available yet? Try to redirect the output of your script to a file to investigate what goes wrong. /usr/bin/bash /home/user/bin/wakeup_script &> /tmp/wakeup.log

    – Thomas
    Mar 17 at 12:36











  • yes, it requires SSH key. How can I resolve this?

    – kuruvi
    Mar 17 at 14:20














  • 2





    Does the rsync command rely on an SSH identity from your user's ~/.ssh? when run by root (from pm-utils) it will be looking in /root/.ssh instead

    – steeldriver
    Mar 17 at 12:35











  • Maybe network is not available yet? Try to redirect the output of your script to a file to investigate what goes wrong. /usr/bin/bash /home/user/bin/wakeup_script &> /tmp/wakeup.log

    – Thomas
    Mar 17 at 12:36











  • yes, it requires SSH key. How can I resolve this?

    – kuruvi
    Mar 17 at 14:20








2




2





Does the rsync command rely on an SSH identity from your user's ~/.ssh? when run by root (from pm-utils) it will be looking in /root/.ssh instead

– steeldriver
Mar 17 at 12:35





Does the rsync command rely on an SSH identity from your user's ~/.ssh? when run by root (from pm-utils) it will be looking in /root/.ssh instead

– steeldriver
Mar 17 at 12:35













Maybe network is not available yet? Try to redirect the output of your script to a file to investigate what goes wrong. /usr/bin/bash /home/user/bin/wakeup_script &> /tmp/wakeup.log

– Thomas
Mar 17 at 12:36





Maybe network is not available yet? Try to redirect the output of your script to a file to investigate what goes wrong. /usr/bin/bash /home/user/bin/wakeup_script &> /tmp/wakeup.log

– Thomas
Mar 17 at 12:36













yes, it requires SSH key. How can I resolve this?

– kuruvi
Mar 17 at 14:20





yes, it requires SSH key. How can I resolve this?

– kuruvi
Mar 17 at 14:20










1 Answer
1






active

oldest

votes


















1














In /usr/lib/pm-utils/sleep.d/example:



after the line:



#!/bin/bash


add the line:



sleep 15


This will give 15 seconds for network interfaces to become available after resuming.






share|improve this answer
























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    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: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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%2faskubuntu.com%2fquestions%2f1126376%2frsync-doesnt-run-when-from-a-bash-script%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









    1














    In /usr/lib/pm-utils/sleep.d/example:



    after the line:



    #!/bin/bash


    add the line:



    sleep 15


    This will give 15 seconds for network interfaces to become available after resuming.






    share|improve this answer




























      1














      In /usr/lib/pm-utils/sleep.d/example:



      after the line:



      #!/bin/bash


      add the line:



      sleep 15


      This will give 15 seconds for network interfaces to become available after resuming.






      share|improve this answer


























        1












        1








        1







        In /usr/lib/pm-utils/sleep.d/example:



        after the line:



        #!/bin/bash


        add the line:



        sleep 15


        This will give 15 seconds for network interfaces to become available after resuming.






        share|improve this answer













        In /usr/lib/pm-utils/sleep.d/example:



        after the line:



        #!/bin/bash


        add the line:



        sleep 15


        This will give 15 seconds for network interfaces to become available after resuming.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 17 at 12:57









        WinEunuuchs2UnixWinEunuuchs2Unix

        47.1k1190183




        47.1k1190183






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Ask Ubuntu!


            • 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%2faskubuntu.com%2fquestions%2f1126376%2frsync-doesnt-run-when-from-a-bash-script%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

            Category:香港粉麵

            List *all* the tuples!

            Channel [V]