Many users running NTPD (Network Time Protocol Daemon) on a virtual machine have encountered an issue where the service fails to start, even though a PID file exists. When checking the status, you might see "ntpd dead but pid file exists." Attempting to restart often shows a "FAILED" shutdown followed by an "OK" start, but the problem persists.
WHAT THE LOGS SAY
A quick look at /var/log/messages
reveals a cryptic error: "cap_set_proc() failed to drop root privileges: Operation not permitted." This message indicates that NTPD, for security reasons, is trying to reduce its power (drop root privileges) but is being prevented from doing so. This often happens in virtualized environments where certain security capabilities are restricted.
THE FIX: EDITING NTPD CONFIGURATION
The solution is surprisingly straightforward and involves a minor adjustment to NTPD's configuration file.
OPEN THE CONFIGURATION FILE: Use a text editor like
vi
to open the NTPD configuration file:vi /etc/sysconfig/ntpd
LOCATE AND COMMENT OUT THE OPTIONS LINE: Find the line that looks like this:
OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"
This line tells NTPD to run as a non-root user (ntp:ntp
), specify its process ID file, and not run in the foreground. The-g
option, in particular, can sometimes cause issues in virtualized setups by preventing the graceful dropping of root privileges.To comment it out, simply add a
#
at the beginning of the line:# OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"
SAVE AND EXIT: Save the changes and exit your text editor. In
vi
, you would typically pressEsc
then type:wq
and pressEnter
.
RESTART NTPD
After making this change, NTPD should now start without issues:
service ntpd start
You should see a successful "Starting ntpd: [ OK ]" message, and the service will run as expected, synchronizing your system's time.