Linux 自动唤醒及关闭的实现方法,linux唤醒


一. 系统休眠(crontab)

示例说明(创建一个 root 定时任务实现每天晚上 11 点 15 分定时关机):

# crontab -e -u root

# m h dom mon dow command

15 23 * * * /sbin/shutdown -h now

示例说明(仅在周一至周五运行)

1 15 23 * * 1-5 /sbin/shutdown -h now

另外可以直接在/etc/crontab文件中添加定时服务

15 23 * * 1-5 root shutdown -h now

二. 唤醒(Wake-On-LAN)

1. 查看是否直接Wake-On-LAN和开启,必须支持的功能是 g

# ethtool eth0 | grep -i wake-on

Supports Wake-on: pumbg

Wake-on: g

2. 启动g(ps:这条命令可能会在重启后失效)

# ethtool -s eth0 wol g

3. 添加cron保证每次重启之后开启g

@reboot /usr/bin/ethtool -s eth0 wol g

 

相关内容