Showing 1 changed files with 7 additions and 3 deletions
+7 -3
rtcwake
... ...
@@ -39,9 +39,13 @@ function set_RTCWAKE_TIME () {
39 39
         RTCWAKE_TIME=$([ $NOW -lt ${AWAKE_TIME//:} ] && date +%s -d $AWAKE_TIME || date +%s -d "tomorrow $AWAKE_TIME")
40 40
     fi
41 41
     suspend_duration=$(( $RTCWAKE_TIME - $(date +%s) ))
42
-    date_awake=$(date -d "$suspend_duration seconds")
43
-    echo "will be awaken in $suspend_duration seconds ($date_awake) (mode=$1)" >> $LOG
44
-    rtcwake -m $1 -s $suspend_duration
42
+    if test $suspend_duration -gt ${MIN_TIME_BEFORE_NEXT_AWAKE:-600}; then
43
+        date_awake=$(date -d "$suspend_duration seconds")
44
+        echo "$NOW: will be awaken in $suspend_duration seconds ($date_awake) (mode=$1)" >> $LOG
45
+        rtcwake -m $1 -s $suspend_duration
46
+    else
47
+        echo "$NOW: no need to suspend because next awake is scheduled in less than $((${MIN_TIME_BEFORE_NEXT_AWAKE:-600} / 60)) minutes"
48
+    fi
45 49
 }
46 50
 
47 51
 case "$1/$2" in