PuppyIP Resource Center
Network & Connection Troubleshooting 9 min Published 2026-11-17

Two Nezha Agent systemd Instances Are Running: Identify and Disable the Duplicate Safely

When multiple Nezha Agent processes appear, map each PID to its systemd unit and monitoring panel before deciding which instance to keep.

Nezha Agent systemd Duplicate instances Linux services cgroup Service cleanup

Service eligibility and regional restrictions

PuppyIP serves only compliant overseas businesses and their authorized personnel. Proxy services are not available in mainland China. The service may only be used for lawful business activities outside mainland China. Use of this service within mainland China is prohibited.

Hosting a proxy IP or server overseas does not change these restrictions. The service must not be provided to end users in mainland China through relaying, forwarding, sharing or resale. Before use, read the Terms of Service.

Key Takeaways

  • Multiple Agent processes may belong to separate units or one unit's child processes; inspect parent and cgroup relationships first.
  • Compare configuration paths, panel destinations and unit state to identify the instance to retain.
  • Stop and disable only a confirmed duplicate unit. Preserve its unit file and configuration in case rollback is needed.
  • After a restart, confirm the intended instance runs, the panel receives new samples and monitoring remains healthy.

Separate multiple processes from multiple systemd units

Multiple Nezha Agent processes on one host can mean duplicated unit installations, or a main process and children managed by one unit. Ending every process by name may stop the only valid monitoring connection. Deleting a unit file may remove configuration or boot behavior still in use.

First identify PIDs, parent PIDs, command lines, cgroups and systemd units. Compare each instance's panel destination, installation directory and runtime user. A process list does not show the full service intent, and an online panel status alone does not tell you which unit is the right one. Compare against authorized host records and known configuration before acting.

Read-only inventory of units, processes and cgroups

Use systemd to list loaded Agent units and boot-enable state, then inspect the process tree and cgroup for each PID. Unit names, paths and options vary by installation method; confirm actual names in the output before replacing the placeholder below. Do not post a complete command line in a public ticket; it may contain a token or panel address.

If there is only one systemd unit but several PIDs, determine whether they are normal child processes of that service before assuming multiple installations. If there are several units, compare ExecStart, user, working directory and configuration source to find a duplicate.

List Agent units and process ownership

sh
UNIT='REPLACE_WITH_CONFIRMED_AGENT_UNIT.service'
systemctl list-units --type=service --all | grep -i nezha
systemctl list-unit-files | grep -i nezha
ps -eo pid,ppid,user,cmd --forest | grep -E '[n]ezha|[a]gent'
systemctl is-active "$UNIT"
systemctl is-enabled "$UNIT"
systemctl status "$UNIT" --no-pager
After confirming the actual unit, read process ownership and original state. Output may contain host usernames, private paths or tokens; do not publish full command lines.

Confirm which monitoring instance should remain

Check the authorized monitoring panel for host identity, last report time and Agent destination. If the two instances connect to different panels, dual monitoring may be intentional. Call one a duplicate only after confirming it is an old installation, test instance or wrong unit. Record the valid unit name, config location and enabled state as your rollback baseline.

Do not decide solely from installation-directory names or unit creation dates. Configuration may be stored outside the default directory, and a management script may generate services. If the destination panel or host ownership is uncertain, remain read-only and ask the asset owner before stopping anything.

Stop and disable only the confirmed duplicate unit

After confirming that the retained unit reports normally, the target is a duplicate and no other monitor depends on it, back up the duplicate unit and referenced configuration. Stop only that unit, check the retained unit's ActiveState and confirm a fresh report for the same host in the Nezha panel. Disable the duplicate in a separate step only after both checks pass. If either check fails, do not disable it or delete files. Never use pkill, killall or a broad process-name loop to end every Agent.

Disabling changes boot-start behavior; it does not remove the unit or its config. Keep those files for rollback. Consider deletion only after confirming that no other script invokes the unit and the recovery check is complete. Service changes may briefly reduce monitoring, so schedule a maintenance window and keep administrator access available.

Stop the confirmed duplicate unit and check the retained service

sh
DUPLICATE_UNIT='REPLACE_WITH_CONFIRMED_DUPLICATE_UNIT.service'
KEEP_UNIT='REPLACE_WITH_CONFIRMED_KEEP_UNIT.service'
sudo systemctl stop "$DUPLICATE_UNIT"
systemctl is-active "$KEEP_UNIT"
Replace both placeholders with the exact verified unit names. After stopping it, confirm the retained unit is still active and the monitoring panel shows a fresh sample for this host. This command does not disable or delete the unit.

Disable the duplicate unit only after verification

sh
DUPLICATE_UNIT='REPLACE_WITH_CONFIRMED_DUPLICATE_UNIT.service'
sudo systemctl disable "$DUPLICATE_UNIT"
Run only after the retained service is stable and the panel has received a fresh sample. This changes boot enablement only; it does not delete the unit or its configuration.

After reboot, check the remaining unit and monitoring samples

After maintenance, inspect the retained unit's ActiveState, SubState, ExecStart and process cgroup. Confirm that the duplicate unit remains inactive or disabled. Then check the Nezha panel for a fresh report from this host, updated monitoring data and healthy reports from other agents. Fewer processes are one useful observation, but do not prove that the remaining Agent connects to the right panel.

If the retained unit stops reporting, restore its unit and configuration backup, start it through systemd and verify its destination and logs. Do not enable full debug or publish complete service logs when they contain credentials.

Rollback and stop conditions

If the retained service stops reporting or rollback is needed, restore the duplicate unit according to its recorded pre-change is-enabled and is-active states; a unit that was disabled must not be enabled by default. Restore only the verified runtime state, then check the monitoring panel and unit ownership again. If the original state was static, masked, failed or another state not covered by the template, stop and use the original management method. Keep the unit file and config backup; do not overwrite the active instance.

Cleanup is complete only when the intended unit runs, the panel receives new samples and a restart does not start an unauthorized second instance. Agent releases can differ in unit templates and process models; use the host's actual systemd state.

Restore the recorded enablement and runtime state

sh
DUPLICATE_UNIT='REPLACE_WITH_CONFIRMED_DUPLICATE_UNIT.service'
ORIGINAL_ENABLED_STATE='REPLACE_WITH_RECORDED_ENABLED_OR_DISABLED'
ORIGINAL_ACTIVE_STATE='REPLACE_WITH_RECORDED_ACTIVE_OR_INACTIVE'
case "$ORIGINAL_ENABLED_STATE" in
  enabled) sudo systemctl enable "$DUPLICATE_UNIT" ;;
  disabled) sudo systemctl disable "$DUPLICATE_UNIT" ;;
  *) printf 'Review the original unit file state before changing it\n' >&2; exit 1 ;;
esac
case "$ORIGINAL_ACTIVE_STATE" in
  active) sudo systemctl start "$DUPLICATE_UNIT" ;;
  inactive) sudo systemctl stop "$DUPLICATE_UNIT" ;;
  *) printf 'Review the original runtime state before changing it\n' >&2; exit 1 ;;
esac
Use only when the recorded pre-change states are enabled/disabled and active/inactive. This template does not cover static, masked or indirect units; restore those through their original manager.

Sources

Frequently Asked Questions

Do two Nezha Agent PIDs prove a duplicate installation?

Not necessarily. One unit may manage a main process and children. Check the parent relationship, cgroup and systemd unit.

Can I pkill every Nezha process?

No. That may stop the only valid monitor. Identify the unit and PID first, then handle only a confirmed duplicate service.

Does disabling a unit remove its configuration?

No. It changes boot-start behavior. Keep a unit and config backup until monitoring is verified.

How do I confirm the retained Agent still works?

Check the unit state and configured destination, then confirm the authorized Nezha panel receives a fresh sample. A running process alone is not enough.