rsync doesn't run when from a bash script
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
add a comment |
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
2
Does thersynccommand rely on an SSH identity from your user's~/.ssh? when run by root (from pm-utils) it will be looking in/root/.sshinstead
– 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
add a comment |
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
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
command-line bash rsync
asked Mar 17 at 12:29
kuruvikuruvi
1011
1011
2
Does thersynccommand rely on an SSH identity from your user's~/.ssh? when run by root (from pm-utils) it will be looking in/root/.sshinstead
– 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
add a comment |
2
Does thersynccommand rely on an SSH identity from your user's~/.ssh? when run by root (from pm-utils) it will be looking in/root/.sshinstead
– 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
add a comment |
1 Answer
1
active
oldest
votes
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.
add a comment |
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
});
}
});
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%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
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.
add a comment |
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.
add a comment |
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.
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.
answered Mar 17 at 12:57
WinEunuuchs2UnixWinEunuuchs2Unix
47.1k1190183
47.1k1190183
add a comment |
add a comment |
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.
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%2faskubuntu.com%2fquestions%2f1126376%2frsync-doesnt-run-when-from-a-bash-script%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
2
Does the
rsynccommand rely on an SSH identity from your user's~/.ssh? when run by root (from pm-utils) it will be looking in/root/.sshinstead– 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