An option to send emails is a required feature in any web app. And, for handling mails, we need a mail server.
Many people prefer to run Sendmail as the mail server as it is free and easy to setup.
Unfortunately, many times these mail servers fail with errors like “Sendmail dead but subsys locked.” And, the fix may not be easy.
That’s why, we often get requests from customers to solve mail server errors as part of our Server Management Services.
Today, we’ll see how our Support Engineers fixed “Sendmail dead but subsys locked” for one of our customers.
What causes Sendmail dead but subsys locked error?
Firstly, let’s see what causes any service to go to ‘Dead’ status and show subsys locked error.
In simple words, this error means the service was running, but crashed recently.
Usually, in Linux servers, starting any service creates a “lock” file. This file helps server to understand that the service is running. Again, it avoids multiple instances of same service. Similarly, stopping the service removes this lock file.
But, when sendmail service crashes accidentally, the lock file exists but the process no longer exists. As a result, it shows the message as:
sendmail dead but subsys locked
For the proper functioning of Sendmail, the configuration file /var/run/sendmail.pid and /var/lock/subsys/sendmail should agree with each other. That is, when the lockfile /var/lock/subsys/sendmail exists, then the first line of the file /var/run/sendmail.pid should contain the PID of the sendmail process running on the server. A missing process with that pid indicates that something is wrong. Again, if the process is running with a different Process ID, that will also result in the error.
Main reasons for the Sendmail error
OK. Now, we know about the error as such. It’s time to see that exact reasons that would cause this.
1. Running alternate service
From our experience in managing the servers, our Dedicated Engineers often see sendmail dead but subsys locked error when another mail service run on the same port. For example, in most Sendmail servers, the Postfix mail server can create problems.
Thus, in effect server tries to run two mail servers on the same port. It fails and result in the error. Usually, the second service will be started by any automated programs on the server like chkconfig or so.
Recently, we saw this error in a DigitalOcean droplet when customer tried to switch the mail server to Postfix. Here, the switch did not complete and resulted in trying to run both process at the same time.
2. Configuration errors
Similarly, Sendmail configuration errors can also result in Sendmail dead error message.
In many cases this happens when the process is unable to start due to a fatal error. Here, the fatal error will be the result of a messed up or missing configuration file /etc/mail/sendmail.cf.
Again, this occurs in scenario where the customer directly edit the sendmail configuration file, without using the ‘m4‘ utility. Here, the system loses the process id information for Sendmail and hence may not be able to shutdown the exact Sendmail process.
Steps to fix the error “Sendmail dead but subsys locked”
We saw the top two reasons for the “Sendmail dead but subsys locked” error. Now, let’s see how our Dedicated Engineers fixed this error for our customer.
Here, the customer approached us asking for the reason for periodic Sendmail failure messages from the server. The alert mail said:
mysqld (pid 1314) is running...
sendmail dead but subsys locked
openssh-daemon (pid 11173) is running...
This was a new server and hence we started the troubleshooting by checking the Sendmail status on the server.
[root@server ~]# /etc/init.d/sendmail status
sendmail dead but subsys locked
sm-client (pid 28752) is running
The error was evident from the results. So, we checked the status of Postfix on the server. It was also running on the server.
[root@server ~]# /etc/init.d/postfix status
-b (pid 1748) is running...
An attempt to stop the Postfix process failed. That’s why, our Dedicated Engineers collected the exact process id of the Postfix process from the ‘netstat‘ command and killed it. After that the sendmail restart command worked perfectly. Finally, Sendmail began running again.
[root@server ~]# service sendmail status
sendmail (pid 15503) is running...
sm-client (pid 15512) is running...
Again, to ensure that Postfix do not automatically restart, we turned it Off in the chkconfig too using the command.
[root@server ~]# chkconfig --level 35 postfix off
[Need help in fixing Sendmail on your server? We are here to help you.]
Conclusion
In short, Sendmail dead but subsys locked error occurs when another service listens on the same port. Today, we saw the top 2 reasons for the error and how our Support Engineers solved it for our customer.
0 Comments