[更新]ubuntu系统定时唤醒开机命令脚步

待机后定时唤醒,本人ubuntu 14.04 LTS
测试例子:待机60秒后唤醒
sudo rtcwake -u -s 60 -m mem


写一个定时的脚本 suspend_until.sh

#!/bin/bash

# Auto suspend and wake-up script
#
# Puts the computer on standby and automatically wakes it up at specified time
#
# Written by Romke van der Meulen <redge.online@gmail.com>
# Minor mods fossfreedom for AskUbuntu
#
# Takes a 24hour time HH:MM as its argument
# Example:
# suspend_until 9:30
# suspend_until 18:45

# ------------------------------------------------------
# Argument check
if [ $# -lt 1 ]; then
echo "Usage: suspend_until HH:MM"
exit
fi

# Check whether specified time today or tomorrow
DESIRED=$((`date +%s -d "$1"`))
NOW=$((`date +%s`))
if [ $DESIRED -lt $NOW ]; then
DESIRED=$((`date +%s -d "$1"` + 24*60*60))
fi

# Kill rtcwake if already running
sudo killall rtcwake

# Set RTC wakeup time
# N.B. change "mem" for the suspend option
# find this by "man rtcwake"
sudo rtcwake -u -m mem -t $DESIRED &

# feedback
echo "Suspending..."

# give rtcwake some time to make its stuff
sleep 2

# then suspend
# N.B. dont usually require this bit
#sudo pm-suspend

# Any commands you want to launch after wakeup can be placed here
# Remember: sudo may have expired by now

# Wake up with monitor enabled N.B. change "on" for "off" if
# you want the monitor to be disabled on wake
# xset dpms force on

# and a fresh console
clear
echo "Good morning!"

chmod +x suspend_until.sh 

比如早上8点半自动唤醒
 suspend_until.sh 8:30 


参考 [url]http://goo.gl/apFmNA[/url] 原文中的定时脚步代码中: sudo rtcwake -l -m mem -t $DESIRED 本人已经修改成 sudo rtcwake -u -m mem -t $DESIRED
修改后的测试时间是完全正确的,只是终端命令中现实出来的时间不对,实际待机唤醒的时间是对的
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值