TSF – Giải pháp IT toàn diện cho doanh nghiệp SMB | HCM

P21 - How to Schedule Automatic Shutdown and Startup of VMs in Proxmox VE

⏰ Proxmox VE – How to Schedule Automatic VM Start and Shutdown Using Cron (Step-by-Step Guide)

Automating virtual machine operations is an essential skill for every Proxmox administrator. In many real-world environments, you may need virtual machines to start and stop at specific times to optimize resource usage, reduce electricity costs, or align with business hours.

Instead of manually powering VMs on and off every day, Proxmox allows you to automate this process using cron jobs combined with the built-in qm command.

In this step-by-step tutorial, you will learn how to:

  • ✅ Identify the correct VMID in Proxmox

  • ✅ Configure cron jobs safely

  • ✅ Schedule automatic VM startup

  • ✅ Schedule automatic VM shutdown

  • ✅ Understand how cron timing syntax works

  • ✅ Apply automation in production or homelab environments

This guide is suitable for both beginners and experienced system administrators managing Proxmox VE.


🖥️ Why Automate VM Start and Shutdown?

Automating VM lifecycle operations provides several benefits:

  • ⚡ Reduce server resource usage outside working hours

  • 💰 Lower electricity and infrastructure costs

  • 🔒 Improve operational control

  • 🧠 Avoid manual mistakes

  • 🔁 Ensure consistent daily routines

For example:

  • Start development VMs at 8:00 AM

  • Shut them down at 6:00 PM

  • Power on lab servers only during training sessions

With cron scheduling, all of this can be handled automatically.


🔎 Step 1: Determine VMID

Before scheduling automation, you must identify the correct VMID of the virtual machine.

📌 Open Proxmox GUI
→ Select the VM
→ Look at the ID number (example: 116)

This VMID will be used in the qm command.


🗂️ Step 2: Open Cron to Schedule

To configure automation, open the user crontab file.

Run:

 
crontab -e

If this is your first time opening crontab, you may be prompted to choose an editor (nano is recommended for beginners).

Cron allows you to schedule commands using time-based rules.


📝 Step 3: Add Timer Line

Cron uses the following format:

 
* * * * * command │ │ │ │ │ │ │ │ │ └── Day of week │ │ │ └──── Month │ │ └────── Day of month │ └──────── Hour └────────── Minute

Now, let’s apply it to real Proxmox automation scenarios.


▶ Example 1 – Schedule to Start VM 116 at 10:30 Every Day

 
30 10 * * * /usr/sbin/qm start 116

Explanation:

  • 30 → Minute

  • 10 → Hour

  • * * * → Every day, every month

  • /usr/sbin/qm start 116 → Start VM with ID 116

This command ensures VM 116 automatically starts at 10:30 daily.


⏹ Example 2 – Schedule to Shut Down VM 116 at 10:35 Every Day

 
35 10 * * * /usr/sbin/qm shutdown 116

Explanation:

  • 35 → Minute

  • 10 → Hour

  • qm shutdown 116 → Gracefully shut down VM 116

This ensures the VM shuts down cleanly at 10:35 every day.


🔍 Understanding the qm Command

Proxmox provides the qm command-line utility for managing virtual machines.

Common commands include:

  • qm start VMID

  • qm shutdown VMID

  • qm stop VMID

  • qm status VMID

In this guide, we use:

  • qm start → Power on VM

  • qm shutdown → Graceful shutdown (recommended over force stop)

Using shutdown allows the guest OS to close safely without risking data corruption.


⚠️ Important Considerations

Before applying automation in production:

  • ✔ Ensure VM is not running critical overnight tasks

  • ✔ Verify correct VMID

  • ✔ Use full path /usr/sbin/qm inside cron

  • ✔ Test command manually before scheduling

  • ✔ Confirm cron service is running

To test manually:

 
/usr/sbin/qm start 116

If the command works manually, it will work in cron.


🚀 Best Practices for Proxmox VM Scheduling

To maintain a stable virtualization environment:

  • Automate non-critical VMs first

  • Avoid overlapping schedules

  • Log cron activity if needed

  • Document automation rules

  • Monitor VM status regularly

For production environments, automation reduces human error and increases operational efficiency.


🎯 Conclusion

In this tutorial, you have learned how to:

  • Identify VMID in Proxmox

  • Use crontab -e to configure scheduling

  • Automate VM startup

  • Automate VM shutdown

  • Apply cron syntax correctly

By leveraging cron automation, you can make your Proxmox environment:

✔ More efficient
✔ More predictable
✔ Less dependent on manual intervention
✔ Better optimized for daily workloads

Automation is a key skill for every System Administrator. Mastering cron scheduling on Proxmox helps you manage virtual infrastructure confidently and professionally.

See also related articles

P15 – Backup and Restore VM in Proxmox VE

P15 – Backup and Restore VM in Proxmox VE 🚀 Proxmox VE P15 – Backup and Restore VMs (Full Step-by-Step Guide) Data protection is one of the most critical responsibilities of any system administrator.In Proxmox VE, having a proper backup and restore strategy ensures your infrastructure can quickly recover from...

Read More

P14 – How to Remove Cluster Group Safely on Proxmox

Proxmox VE 9 P14: How to Remove Cluster Group Safely In Proxmox (Step-by-Step Guide) 🚀 Proxmox VE 9 – How to Remove Cluster Group (Step-by-Step) In some scenarios, you may need to remove a Proxmox cluster configuration completely, especially when: ❌ A node failed permanently ❌ The cluster was misconfigured...

Read More