Linux实现每3天23点定时重启服务器
使用crontab
创建重启脚本
# 创建脚本文件
vim /opt/auto_reboot.sh# 脚本内容:
#!/bin/bash
echo "$(date): 执行定时重启" >> /var/log/auto_reboot.log
/sbin/reboot
# 给脚本执行权限
chmod +x /usr/local/bin/auto_reboot.sh配置crontab
# 编辑root的crontab
crontab -e# 添加以下行(每3天的23点执行)
0 23 */3 * * /usr/local/bin/auto_reboot.sh