电脑疯子技术论坛|电脑极客社区

 找回密码
 注册

QQ登录

只需一步,快速开始

[linux教程] 设置自动唤醒和关闭 Linux

[复制链接]
zhaorong 发表于 2018-1-9 14:31:01 | 显示全部楼层 |阅读模式

一. 系统休眠(crontab)

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

  1. 1 # crontab -e -u root
  2. 2 # m h  dom mon dow   command
  3. 3 15 23 * * * /sbin/shutdown -h now
复制代码

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

  1. 1 15 23 * * 1-5 /sbin/shutdown -h now
复制代码


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

  1. 15 23 * * 1-5 root shutdown -h now
复制代码


二. 唤醒(Wake-On-LAN)

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

  1. # ethtool eth0 | grep -i wake-on
  2.   Supports Wake-on: pumbg
  3.   Wake-on: g
复制代码


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

  1. # ethtool -s eth0 wol g
复制代码


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

  1. @reboot /usr/bin/ethtool -s eth0 wol g
复制代码


您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|VIP|电脑疯子技术论坛 ( Computer madman team )

GMT+8, 2025-2-2 21:49

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表