LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Laptop and Netbook
User Name
Password
Linux - Laptop and Netbook Having a problem installing or configuring Linux on your laptop? Need help running Linux on your netbook? This forum is for you. This forum is for any topics relating to Linux and either traditional laptops or netbooks (such as the Asus EEE PC, Everex CloudBook or MSI Wind).

Notices


Reply
  Search this Thread
Old 02-11-2016, 01:36 PM   #1
kwhitefoot
LQ Newbie
 
Registered: Feb 2016
Location: Norway
Distribution: Mint, Ubuntu, Debian
Posts: 2

Rep: Reputation: Disabled
Question sleep does not return after machine wakes from suspend


I have a script that backs up my Nokia N9.
It sits in a loop waiting for the directory to appear sleeping 60 seconds between checks.

If I start this in a terminal it works nicely but if I suspend the machine while the sleep command is running it never returns because sleep never finishes.

Here is the script that waits for the directory to appear:

wait_for_dir.sh:

#!/bin/bash

# Just for debugging.
#set -o verbose

dir=$1
interval=$2
echo "$dir"
while [ ! -d "$dir" ]
do
NOW=$(date "+%Y-%m-%dT%T")
echo "${NOW}: Waiting for ${dir}, sleeping ${interval}"
sleep ${interval}
done

I call it like this:

./wait_for_dir.sh "/media/kj/Nokia N9" 60s

Any idea why sleep doesn't return? Any suggestions for an alternative?

I use this as a component in a larger script that waits for the N9 and uses rsync to take a backup. Once the backup is complete it waits for the N9 to disappear and reappear before taking another backup.
 
Old 02-13-2016, 05:04 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by kwhitefoot View Post
If I start this in a terminal it works nicely but if I suspend the machine while the sleep command is running it never returns because sleep never finishes.
are you sure this assessment is correct?
i would rather assume that the script terminates when the machine is suspended.

in any case, you should add commands to terminate before & restart the script(s) after suspend.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SIGIO sigaction wakes sleep up early bldrco Programming 2 07-09-2009 08:56 AM
ACPI Suspend / Sleep Galib Linux - Laptop and Netbook 3 04-03-2009 07:06 AM
LXer: Midnight Commander wakes from deep sleep LXer Syndicated Linux News 0 02-02-2009 12:50 PM
Standby/Sleep immediately wakes up again bsander Linux - Laptop and Netbook 2 05-07-2005 03:29 PM
How to use ACPI to sleep/suspend? manueljose Linux - Laptop and Netbook 2 09-28-2004 10:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Laptop and Netbook

All times are GMT -5. The time now is 06:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration