This tutorial provides a setup for automating the reboot of a Proxmox VM, In my case, I utilised this to manage RAM bloat for my Minecraft server VM. A cron job runs a bash script at 5:00 AM (when my friends are most likely not playing I hope 💀) every 3 days to reboot the VM, ensuring stable performance.
- Proxmox VE installed and configured.
- A Proxmox VM.
- Sudo/root access to the Proxmox host.
- Log in to your Proxmox host.
- Create a directory for scripts if it doesn’t already exist (assuming you are root user):
mkdir /root/scripts
- Create
reboot.sh
script:touch /root/scripts/reboot.sh
- Add the follow code to the script:
#!/bin/bash qm reboot $1 # takes the first argument as the VM number
Before setting up the cron job, test the script manually:
bash /root/scripts/reboot.sh <VM Number>
This will reboot the specified VM.
- Open the crontab editor:
crontab -e
- Add the following line to schedule the job at 5:00 AM every 3 days:
0 5 */3 * * bash /root/scripts/reboot.sh <VM Number>
- The
qm reboot
command is specific to Proxmox and can be found in the documentation - Ensure the cron job has sufficient permission to execute the file path
- if issues arise, system logs can be checked with:
journalctl -t CRON