delays on VM startups

gralf

New Member
Nov 2, 2024
17
1
3
Hi there, long time ago I set up a delay to the startup of one of my VMs, the point is I remeber doing it via a script and some systemd stuff.

Now I want to remove that delay, and I need some hints on how to find the created script.
 
hi, thank you for your reply, I have checked /etc/pve/qemu-server/100.conf


and does not point to any file, I remember that I made a script and then setup systemctl to read it, but don´t remember anything else.
 
Well, if you created a systemd unit or similar, you could search for it in /etc/systemd/system/.
Or check and filter units with systemctl list-units '*searchterm*' or systemctl list-unit-files '*searchterm*'?
 
The point is I dont remember the name .

This is the learnt lesson, keep note of every change made on the server.

Even though i will search using some wildcards .

Thx
 
You can run a script which checks all relevant services, cronjobs, etc. Save it (for example) as „check-delay.sh“ and make it executable with:

chmod +x <filename>

After that, run the script with:

bash <filename>

Code:
#!/bin/bash

echo "=== VM Startup Delay Diagnostic Script ==="
echo "Host: $(hostname)"
echo "Date: $(date)"
echo

###############################################################################
# SECTION 1: Check enabled systemd units that may introduce delays
###############################################################################
echo ">>> Checking enabled systemd units..."
systemctl list-unit-files --state=enabled | grep -Ei "hook|wait|delay|custom|local"
echo

###############################################################################
# SECTION 2: Check systemd unit files for explicit 'sleep' commands
###############################################################################
echo ">>> Searching systemd units for 'sleep' statements..."
grep -Rnw "/etc/systemd" -e "sleep" 2>/dev/null
grep -Rnw "/usr/lib/systemd" -e "sleep" 2>/dev/null
echo

###############################################################################
# SECTION 3: Check scripts that may run on boot
###############################################################################
echo ">>> Searching /usr/local/bin and /root for scripts containing 'sleep'..."
grep -Rnw "/usr/local/bin" -e "sleep" 2>/dev/null
grep -Rnw "/root" -e "sleep" 2>/dev/null
echo

###############################################################################
# SECTION 4: Check cron jobs for delays
###############################################################################
echo ">>> Checking cron for delay-related commands..."
grep -Rnw "/etc/cron" -e "sleep" 2>/dev/null
crontab -l 2>/dev/null | grep -i sleep
echo

###############################################################################
# SECTION 5: Check global and per-VM hook scripts in Proxmox
###############################################################################
echo ">>> Checking Proxmox hookscript references..."
grep -Rnw "/etc/pve" -e "hookscript" 2>/dev/null

echo
echo ">>> Checking hookscript references in VM configurations..."
grep -Rnw "/etc/pve/qemu-server" -e "hookscript" 2>/dev/null
echo

###############################################################################
# SECTION 6: Identify slow systemd services (≥3s startup time)
###############################################################################
echo ">>> Listing slow systemd services..."
systemd-analyze blame | head -20
echo

###############################################################################
# SECTION 7: Check logs for VM-related delays
###############################################################################
echo ">>> Scanning logs for VM startup delays..."
journalctl -u pvedaemon.service --since "today" | grep -Ei "delay|sleep|wait|timeout"
echo

echo "=== Completed diagnostics ==="
echo