[SOLVED] Start VM everyday at 7:00am

jjm

Member
Oct 3, 2020
5
2
8
47
Hi to all,
I m looking for a sulution for start VM(105) everyday at 7:00 if it is stopped.
it's not worked in crontab.


start.sh
#! /bin/bash
status=`qm status 105 | awk -F " " '{print $2}'`
if [ $status = "stopped" ] ; then
qm start 105
fi

crontab -l
0 7 * * * /var/lib/vz/snippets/105/start.sh

logs:
Feb 23 07:00:00 proxmox systemd[1]: Starting Proxmox VE replication runner...
Feb 23 07:00:01 proxmox systemd[1]: pvesr.service: Succeeded.
Feb 23 07:00:01 proxmox systemd[1]: Started Proxmox VE replication runner.
Feb 23 07:00:01 proxmox CRON[21835]: pam_unix(cron:session): session opened for user root by (uid=0)
Feb 23 07:00:01 proxmox CRON[21836]: (root) CMD (/var/lib/vz/snippets/105/start.sh)
Feb 23 07:00:02 proxmox CRON[21835]: pam_unix(cron:session): session closed for user root
Feb 23 07:00:02 proxmox postfix/pickup[9174]: 1395923055: uid=0 from=<root>
Feb 23 07:00:02 proxmox postfix/cleanup[21843]: 1395923055: message-id=<20240222230002.1395923055@proxmox.host>
Feb 23 07:00:02 proxmox postfix/qmgr[4756]: 1395923055: from=<root@proxmox.host>, size=675, nrcpt=1 (queue active)
Feb 23 07:00:02 proxmox pvemailforward[21847]: forward mail to <root@local.host>
 
Last edited:
status=`qm status 105 | awk -F " " '{print $2}'`
crontab does not load user profile, hence there is no PATH, so it cant find "qm" binary (most likely).
Always use absolute paths in crontab scripts, unless you also load appropriate variables within the script.

P.S.
Test you scripts with every min execution of "qm status" for example, or "qm list", dumping output to file


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
Last edited:
  • Like
Reactions: alyarb
if needed, use which to find the full path to all of the executables in your crons. always use the complete path
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!