It's a good idea to sanity check your config changes before attempting to reload/restart a service. The following commands return non-zero on failure, so can be used in scripting, or in orchestration tools, such as Ansible's ''validate:'' directive. Or interactively, you could string them together like:
checkcommand && reloadcommand
apachectl configtest
named-checkconf
named-checkzone opticomm.net.au /var/named/opticomm.net.au.zone
Debian/Cumulus Interfaces file:
ifreload -as
dhcpd -t -cf /etc/dhcp/dhcpd.conf
icinga2 daemon -C
iptables-restore --test /etc/sysconfig/iptables
keepalived -t -f /etc/keepalived/keepalived.conf
mysqld --verbose --help 1>/dev/null
sudo netplan try --timeout 0 && sudo netplan apply
sudo nginx -tc /etc/nginx/nginx.conf
sshd -t
openvpn --config /path/to/server.conf # runs a second instance in foreground
postfix check
<pre>php -r ''</pre>
sudo php-fpm -t
radiusd -C # rhel
freeradius -C # debian
squid -k check
/usr/sbin/visudo -c
bash -n script.sh
perl -c script.pl
python -m py_compile script.py
php -l script.php