可以的。Debian 下完全可以通过“定时器”来定时重启系统,常见的做法有两种,取决于你用的定时机制:
Debian 9 及以后默认使用 systemd,可以用 systemd timer 定时执行重启。
sudo vim /etc/systemd/system/reboot-job.service
内容:
[Unit]
Description=Reboot System
[Service]
Type=oneshot
ExecStart=/sbin/reboot
sudo vim /etc/systemd/system/reboot-job.timer
例如:每天凌晨 3 点重启
[Unit]
Description=Daily Reboot Timer
[Timer]
OnCalendar=*-*-* 03:00:00
Persistent=true
[Install]
WantedBy=timers.target
sudo systemctl daemon-reexec
sudo systemctl enable --now reboot-job.timer
查看状态:
systemctl list-timers
如果你更习惯 cron:
sudo crontab -e
添加一行(每天 3 点重启):
0 3 * * * /sbin/reboot
echo 测试定时器是否触发:ExecStart=/usr/bin/echo "reboot test"
OnCalendar=Sun *-*-* 04:00:00
OnCalendar=*:00/6
如果你告诉我 Debian 版本 / 是服务器还是桌面 / 重启频率,我可以帮你写一份更合适的配置。