Skip to Content
Back to Portfolio

proxmox-vm-scheduler

Author
RamonRiosJr
Repository Author

Proxmox VM Scheduler

A lightweight C++ utility designed to automate the lifecycle of Proxmox VE Virtual Machines and LXC Containers. This tool interacts directly with the Proxmox REST API to start, stop, or shutdown instances, making it ideal for managing development environments that do not need to run 24/7.

Features

  • Direct API Integration: Uses libcurl to communicate with the Proxmox api2/json endpoints.
  • Secure Authentication: Supports Proxmox API Tokens (PVEAPIToken), avoiding the need to store user passwords in plain text.
  • Resource Optimization: Can be coupled with Cron jobs to automatically shut down high-resource development servers (e.g., Odoo Dev) at night and wake them in the morning.
  • Container & VM Support: Easily configurable for both QEMU VMs and LXC Containers.

Prerequisites

  • OS: Ubuntu/Debian (or any Linux distro)
  • Libraries: libcurl
    sudo apt update
    sudo apt install libcurl4-openssl-dev
  • Proxmox: Access to a Proxmox VE server (Version 6.0+).

API Token Setup

To use this tool securely, generate an API Token in your Proxmox GUI:

  1. Go to Datacenter > Permissions > API Tokens.
  2. Click Add.
  3. User: root@pam (or your preferred user).
  4. Token ID: coqui_automation (or similar).
  5. Important: Uncheck "Privilege Separation" if running as root, or assign specific permissions.
  6. Copy the Secret immediately (you won't see it again).

Configuration

Edit the vm_scheduler.cpp file with your specific infrastructure details:

'cpp const std::string PROXMOX_HOST = "https://192.168.1.50:8006"; const std::string NODE_NAME = "pve"; const std::string API_USER = "root@pam!user_automation"; const std::string API_TOKEN = "YOUR_UUID_SECRET_KEY"; const std::string TARGET_VM_ID = "105"; // The ID of the VM to control

Note: If controlling a VM (QEMU) instead of a Container (LXC), change /lxc/ to /qemu/ in the url string construction in the source code.

Compilation

Bash

g++ -std=c++17 vm_scheduler.cpp -o vm_sched -lcurl

Usage

Start the Server:

Bash

./vm_sched start

Graceful Shutdown:

Bash

./vm_sched shutdown

Force Stop (Kill):

Bash

./vm_sched stop

Automation Example (Cron)

  • To save electricity and server resources, add this to your crontab (crontab -e) to shut down the server every night at 8 PM: Bash

0 20 * * * /path/to/vm_sched shutdown >> /var/log/vm_sched.log 2>&1

Maintained By

Coqui Cloud - IT Solutions & Custom Software

Recent Activity

Update Proxmox host and API user credentials2026-02-01
Ramon Rios
Modify copyright holder in LICENSE file2026-01-26
Ramon Rios
Update API_USER in README for automation user2026-01-26
Ramon Rios

About Ramon Rios Jr's Tech Stack

As a Senior Systems Architect and Full Stack Developer, I specialize in building scalable, enterprise-grade applications. My expertise spans across modern backend frameworks using Python, comprehensive ERP deployments with Odoo, and highly interactive frontend architectures. The open-source GitHub repositories listed above demonstrate my proficiency in API development, database optimization, system integrations, and automation. Whether crafting custom business logic or designing sleek glassmorphic user interfaces, I am committed to delivering high-performance software solutions.