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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.