Cron job to consistently reboot a VM on TrueNAS CORE

Simple question.

Can reboot the VM from within the VM via cron but if it crashes (And CORE VMs can and do crash far more than most hypervisors, so be it, I’m used to it)

I’ve discovered the command “virsh reboot” but the command seems to rely on entering a number which regularly changes (is it a PID?)

So how do I consistently reboot my VM at about 6am, anyone know?

Please and thanks to anyone who can help.

I am still having difficulty with this, the command worked infrequently for me.

I googled significantly and had real problems getting something to CONSISTENTLY work.
I get this error for example:

bhyvectl --vm=23_ProxBackupVM --force-reset

=

vm_open: 23_ProxBackupVM could not be opened: No such file or directory

Does anyone know a consistent command to totally reboot (heck, reset) a VM each night on CPRE?

midclt call vm.query | jq

to find the id of your VM, then

midclt call vm.restart <id>

Thanks to @Samuel_Tai who posted this solution on the old forum.

Thank you, it looks like that number is consistent (23) and therefore, your command will reboot it each night, just need to adjust my cron job.

Thanks so much.

@pmh Yeah I can confirm my proxmox backup server is now alive more often than it was.

This is an old problem I had long long ago on TrueNAS Core, like 3 or 4 years, my Ubuntu DockerVM would fall over inconsistently no idea why.

Is this a “safe” or “messy” reboot?
Regardless, thank you, she’s in a better state now.

Wonder if this would help, it seems @pmh may have figured out one of the issues

Thanks I’ve replied there, heck of a thing, I’d be willing to try.