CentOS7下Sendmail服务启动失败求助:模糊报错排查
Hey there, let's break down this Sendmail problem you're facing. From the truncated logs you shared, we can spot two key details:
- Sendmail's daemon actually successfully starts up (the line
sendmail[3712]: starting daemon (8.14.7): SMTP+queueing@01:00:00confirms this) - Systemd is throwing a warning about not being able to read the PID file
/run/sendmail.pidright after launch
This is almost always a timing mismatch between systemd's quick check and Sendmail's PID file creation, or a permission/configuration misalignment. Here's how to debug it step by step:
Step 1: Verify Sendmail is running and check PID file details
First, confirm if Sendmail is actually active in the background:
ps aux | grep sendmail | grep -v grep
If you see running Sendmail processes, check if the PID file exists and what permissions it has:
ls -l /run/sendmail.pid
The file should be owned by root:root with at least 644 permissions (so systemd can read it). If it's missing or has overly restrictive permissions, that's a clear red flag.
Step 2: Fix systemd service timing or configuration
Systemd might be checking for the PID file too quickly before Sendmail has a chance to write it. Let's adjust the service file:
- Open the Sendmail systemd service file (usually located here):
vi /usr/lib/systemd/system/sendmail.service
- Look for the
TimeoutStartSecparameter. If it's missing or set to a low value (like 10), increase it to give Sendmail more time to create the PID file:
TimeoutStartSec=30
- Also double-check that the
PIDFileline correctly points to/run/sendmail.pid(it needs to match the path Sendmail uses). - Save the file and reload systemd to apply changes:
systemctl daemon-reload
- Restart Sendmail and check the status:
systemctl restart sendmail.service systemctl status sendmail.service
Step 3: Confirm Sendmail's PID file configuration
Sendmail might be configured to write its PID file to a different location. Check its main config file:
grep -i "pidfile" /etc/mail/sendmail.cf
Look for a line like O PidFile=/run/sendmail.pid. If it points to another path (like /var/run/sendmail.pid), you'll need to:
- Either update Sendmail's config to use
/run/sendmail.pid(then restart Sendmail) - Or update the
PIDFileline in the systemd service file to match Sendmail's path (then reload systemd and restart Sendmail)
Step 4: Get the full systemd log
Your original log was truncated (ends with se...). To see the complete error message, run:
journalctl -u sendmail.service --since "2024-04-12 01:00"
This will show all Sendmail-related logs from around the time of the failure, which might reveal additional hidden issues we haven't spotted yet.
内容的提问来源于stack exchange,提问作者aannjose

