skip to content
Logo I like chickens.
they're persistent.
Faust
you better try google.com...
中文

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 file
if [ ! -f "$AGENT_BIN" ]; then
echo "Error: Executable file $AGENT_BIN not found"
exit 1
exit 1
[ ! -x "$AGENT_BIN" ] && chmod +x "$AGENT_BIN"
# Key check: determine if the process already exists
if 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 0
exit 0
# Background startup
nohup "$AGENT_BIN" >/dev/null 2>&1 &
echo "Nezha Agent started (PID: $!)"
``