4 PIDFILE=/var/run/ntpd.pid
7 NTPD_OPTS="-g -u $USER:$GROUP -p $PIDFILE"
10 if [ -r $PIDFILE ]; then
11 echo "ntpd seems to be already running under pid `cat $PIDFILE`."
12 echo "Delete $PIDFILE if this is not the case.";
15 echo -n "Starting NTP daemon... "
19 # You can't always rely on the ntpd exit code, see Bug #2420
29 if ps -Ao args|grep -q "^$NTPD $NTPD_OPTS"; then
34 [ -e $PIDFILE ] && rm $PIDFILE
40 if [ ! -r $PIDFILE ]; then
41 echo "ntpd doesn't seem to be running, cannot read the pid file."
44 echo -n "Stopping NTP daemon...";
47 if kill -TERM $PID 2> /dev/null;then
48 # Give ntp 15 seconds to exit
49 for i in `seq 1 15`; do
50 if [ -n "`ps -p $PID|grep -v PID`" ]; then
61 echo " FAILED! ntpd is still running";
66 if [ -r $PIDFILE ]; then
67 echo "NTP daemon is running as `cat $PIDFILE`"
69 echo "NTP daemon is not running"
81 ntpd_stop && ntpd_start
87 echo "Usage: $0 (start|stop|restart|status)"