Nezha Probe Agent Bailout Script
This article is machine-translated.
#!/bin/bash
# Nezha Agent Single Instance Background Startup Scripts# Function: Prevent duplicate startups, ensure unique processes
AGENT_BIN="/usr/home/xxx/nazha-agent/nezha-agent"PROCESS_NAME="nezha-agent" # Adjust to the actual process name (check with ps)
# Check the program fileif [ ! -f "$AGENT_BIN" ]; then echo "Error: Executable file $AGENT_BIN not found" exit 1exit 1[ ! -x "$AGENT_BIN" ] && chmod +x "$AGENT_BIN"
# Key check: determine if the process already existsif pgrep -f "$PROCESS_NAME" > /dev/null; then echo "Prompt: nezha-agent is already running, no need to restart!" echo "PID list: $(pgrep -f "$PROCESS_NAME" | tr '\n' ' ')" exit 0exit 0
# Background startupnohup "$AGENT_BIN" >/dev/null 2>&1 &echo "Nezha Agent started (PID: $!)"``