External commands let Nagios Core accept runtime instructions through a local command file while the monitoring daemon is already running. Web CGI actions such as forced checks, acknowledgements, and downtime scheduling use this path, and local integrations can submit supported commands to the same interface.
The main nagios.cfg file controls whether the daemon reads external commands, where the command FIFO is created, and whether received commands are logged. On Debian and Ubuntu package installs, the command file is normally /var/lib/nagios4/rw/nagios.cmd; source installs often use /usr/local/nagios/var/rw/nagios.cmd instead.
Nagios Core creates nagios.cmd as a FIFO when the daemon starts, not as a regular file that should be created by hand. Write access belongs only to trusted command senders, such as the web server user for cmd.cgi or a local automation account that submits passive results.
$ sudoedit /etc/nagios4/nagios.cfg
Use the active main configuration file for that install. Source installs commonly use /usr/local/nagios/etc/nagios.cfg.
check_external_commands=1 command_file=/var/lib/nagios4/rw/nagios.cmd log_external_commands=1
Nagios Core 4 processes external commands as soon as they are received. Older command_check_interval settings do not control processing on current Nagios Core 4 systems.
$ sudo usermod --append --groups nagios www-data
Debian and Ubuntu packages commonly use the nagios group for the command FIFO. Source-install quickstarts may use a dedicated group such as nagcmd instead; add only trusted command-submit users to that group.
$ sudo nagios4 -v /etc/nagios4/nagios.cfg Nagios Core 4.4.6 ##### snipped ##### Reading configuration data... Read main config file okay... Read object config files okay... ##### snipped ##### Total Warnings: 0 Total Errors: 0 Things look okay - No serious problems were detected during the pre-flight check
Use sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg on source installs that follow the upstream default layout.
Related: How to validate the Nagios Core configuration
$ sudo systemctl restart nagios4
Use the service name for the installed package or source-install service. Debian and Ubuntu packages use nagios4.
Related: How to manage the Nagios Core system service
$ sudo systemctl restart apache2
Existing web server worker processes keep their old group list until they restart. Use the local web server unit name when the monitoring UI does not run under apache2.
Related: How to manage the Apache web server service
$ sudo ls -ld /var/lib/nagios4/rw /var/lib/nagios4/rw/nagios.cmd drwxrwsr-x 1 nagios nagios 4096 Jun 22 01:19 /var/lib/nagios4/rw prw-rw---- 1 nagios nagios 0 Jun 22 01:19 /var/lib/nagios4/rw/nagios.cmd
The leading p on nagios.cmd means it is a FIFO. Keep the group limited to the web server or automation accounts that should be allowed to submit commands.
$ now=$(date +%s)
$ printf '[%s] SCHEDULE_FORCED_HOST_CHECK;localhost;%s\n' "$now" "$now" | sudo tee /var/lib/nagios4/rw/nagios.cmd [1782091273] SCHEDULE_FORCED_HOST_CHECK;localhost;1782091273
Replace localhost with a real host from the monitoring server. A forced host check is a low-impact test because it asks Nagios Core to run an existing active check.
Related: How to reschedule an active check in Nagios Core
$ sudo cat /var/log/nagios4/nagios.log [1782091195] Nagios 4.4.6 starting... (PID=34) [1782091195] Local time is Mon Jun 22 01:19:55 UTC 2026 ##### snipped ##### [1782091273] EXTERNAL COMMAND: SCHEDULE_FORCED_HOST_CHECK;localhost;1782091273
If log_external_commands is disabled, verify the same action from the web interface or through the affected host state.
Related: How to check Nagios Core logs