Hello,
I am trying to start/stop vm's based off status of other VM's. However, I am unable to get the script to work.
Here is my bash script:
Cron tab:
When I run this via the shell it works just fine and reports the correct status. When it is ran via crontab it does not report the
I am hoping someone on this forum may know what I am doing wrong and help pulling the correct status to be used in a script.
I am trying to start/stop vm's based off status of other VM's. However, I am unable to get the script to work.
Here is my bash script:
Bash:
#!/bin/bash
if [ "$(qm status 107)" != "status: running" ]; then
/usr/sbin/qm start 107
/usr/sbin/qm shutdown 106
fi
Cron tab:
* * * * * /bin/bash /var/scripts/checkvm.sh
When I run this via the shell it works just fine and reports the correct status. When it is ran via crontab it does not report the
qm status 107
correctly. When I echo and output to a file it is blank and does not have "status: running".I am hoping someone on this forum may know what I am doing wrong and help pulling the correct status to be used in a script.
Last edited: