Friday, March 18

CentOS/RHEL 7 Mailscanner + sendmail, prevent systemd stop sendmail with stopms option

In CentOS 6 and previous versions, running "/etc/init.d/MailScanner stopms" will terminate MailScanner processes only, without stopping the sendmail processes.

However on CentOS 7, init was replaced by systemd. systemd would treat the MailScanner and sendmail process at one service, if you stopms or kill MailScanner, systemd will run "/etc/init.d/MailScanner stop" to stop the sendmail processes too.

Make the following changes to overcome this issue:
# mkdir /etc/systemd/system/MailScanner.service.d
create custom_script.conf with followings:
[Service]
RemainAfterExit=yes

# systemctl daemon-reload


Reference:
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sect-Managing_Services_with_systemd-Unit_Files.html#brid-Managing_Services_with_systemd-Overriding_Unit_Mod
http://www.unix.com/man-page/centos/5/systemd.service/

RemainAfterExit=
  Takes a boolean value that specifies whether the service shall be considered active even when all its processes exited. Defaults to no.

No comments: