<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>stopped &#8211; SMsoft &#8211; informatica e dintorni</title>
	<atom:link href="https://blog.smsoft.it/tag/stopped/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.smsoft.it</link>
	<description>consigli settimanali su MacOS, GNU/Linux ed Open Source</description>
	<lastBuildDate>Thu, 13 Jul 2023 08:43:23 +0000</lastBuildDate>
	<language>it-IT</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=64339</generator>
	<item>
		<title>Proxmox: riavviare una VM se è spenta</title>
		<link>https://blog.smsoft.it/2023/08/15/proxmox-riavviare-una-vm-se-e-spenta/</link>
					<comments>https://blog.smsoft.it/2023/08/15/proxmox-riavviare-una-vm-se-e-spenta/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 15 Aug 2023 08:30:00 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Proxmox]]></category>
		<category><![CDATA[restart]]></category>
		<category><![CDATA[stopped]]></category>
		<guid isPermaLink="false">https://blog.smsoft.it/?p=6034</guid>

					<description><![CDATA[L&#8217;attuale versione di Proxmox non ha un sistema di verifica e riavvio delle VM se finiscono in stato &#8220;stopped&#8221;. E&#8217; possibile creare un semplice script bash, da eseguire periodicamente tramite CRON, con il seguente contenuto: enjoy!]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">L&#8217;attuale versione di Proxmox non ha un sistema di verifica e riavvio delle VM se finiscono in stato &#8220;stopped&#8221;.</p>



<p class="wp-block-paragraph">E&#8217; possibile creare un semplice script bash, da eseguire periodicamente tramite CRON, con il seguente contenuto:</p>



<pre class="wp-block-code"><code>#!/bin/bash
exec 1> >(logger -s -t $(basename $0)) 2>&amp;1 #loggare nel syslog l'output dello script
export NODE=localhost

#pvesh create /nodes/$NODE/qemu/100/status/shutdown # Spegnere
#pvesh create /nodes/$NODE/qemu/100/status/start # Accendere

VMIDS=$(cat /etc/pve/.vmlist |jq '.ids | keys&#91;]') #recupero l'elenco di tutte le VM
VMIDS="100 101 102 103 104 106" #se voglio definire solo alcune VM
echo $VMIDS
for VMID in $VMIDS; do

### inizio procedura usando pvesh ###
    VMID=$(echo $VMID |grep -o -E '&#91;0-9]+')
    echo "the next VM is $VMID"
    STATUS=$(pvesh get /nodes/$NODE/qemu/$VMID/status/current --output-format json | jq '.status')
    echo $STATUS
    if &#91; $STATUS == '"stopped"' ]; then
        echo "$VMID is stopped"
        pvesh create /nodes/$NODE/qemu/$VMID/status/start # POST
    fi
### fine procedura usando pvesh ###

### inizio procedura usando qm ###
#   if &#91;&#91; $(qm status $VMID) = *"status: stopped"* ]]; then
#       echo "$VMID is stopped"
#       qm start $VMID
#   fi
### fine procedura usando qm ###

done</code></pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">enjoy!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.smsoft.it/2023/08/15/proxmox-riavviare-una-vm-se-e-spenta/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
