Schedule Proxmox VM Startup and Shutdown with Cron
i12bretro
#Proxmox #Scheduling #CRON
Full steps can be found at https://i12bretro.github.io/tutorials/0849.html
What is Cron?
The cron daemon is a background process that runs particular programs at particular times (for example, every minute, day, week, or month), as specified in a crontab. By default, users may also create crontabs of their own so that processes are run on their behalf. - https://packages.debian.org/stable/cron 01. Log into Proxmox VE either via SSH or the web based shell 02. Run the following commands in the terminal # verify the location of qm # should output /usr/sbin/qm which qm # list the configured vms qm list 03. Note the VMID of the target VM(s) 04. Determine the startup and shutdown schedule requirements for each target VM 05. Convert the startup and shutdown schedules to cron format, https://crontab.guru/ is a great utility to visualize them 06. Continue with the following commands in the terminal # edit the cron table file crontab -e # if prompted, select nano from the list of editors 07. At the bottom of the file, add an entry for the start and stop of each target VM in the following format ≪%cron schedule%≫ /usr/sbin/qm ≪%start|shutdown%≫ ≪%VMID%≫ 55 6 * * * /usr/sbin/qm start 100 5 23 * * * /usr/sbin/qm shutdown 100 08. Press CTRL+O, Enter, CTRL+X to write the changes and close nano 09. In the example above, VM 100 will be started at 6:55 AM and shutdown at 11:05 PM everyday 10. Cron schedules can be extremely flexible with some creativity, some examples: https://crontab.guru/#55_6_*_*_1-5 55 6 * * 1-5 /usr/sbin/qm start 100 https://crontab.guru/#0_9_*_*_6,0 0 9 * * 6,0 /usr/sbin/qm start 100 https://crontab.guru/#0_7_*_*_1,3,5 0 7 * * 1,3,5 /usr/sbin/qm start 100 11. Linux Containers (lxc) can be controlled via the pct command 55 6 * * 1-5 /usr/sbin/pct start 103 0 9 * * 6,0 /usr/sbin/pct start 103 0 7 * * 1,3,5 /usr/sbin/pct start 103
Connect with me and others
★ Discord: https://discord.com/invite/EzenvmSHW8 ★ Reddit: https://reddit.com/r/i12bretro ★ Twitter: https://twitter.com/i12bretro ... https://www.youtube.com/watch?v=T5Hhl7aH4XQ
14665708 Bytes