3

I'm maintaining some cronjobs on machines that are set to be patched to the service pack of SLES11sp4, it appears that the service pack is upgrading sntp from version 4.2.4p8 to 4.2.8p2 and somewhere in the midst of those releases they dropped the "-P" parameter.

From the old man page:

-P prompt
    sets the maximum clock change that will be made automatically to     
 maxerr. Acceptable values are from 1 to 3600 or no, and the default is  
 30. If the program is being run interactively in ordinary client mode, 
 and the system clock is to be changed, larger corrections will prompt 
 the user for confirmation. Specifying no will disable this and the 
 correction will be made regardless. 

and I use it in a cron job very simply:

/usr/sbin/sntp -P no -r $ips[1] >& /dev/null
/usr/sbin/sntp -P no -r $ips[2] >& /dev/null

where $ips are hopefully some ip addresses.

I didn't see anything in the new version that looked like this or a quiet mode or anything useful. So is this just the default now and I can just remove the "-P" or is there something else that needs doing

  • Did -P have any effect when called from a cron job? The man page says it only prompts if it's run interactively, which is not true of a cron job. – Mikel Nov 9 '15 at 15:49
  • @mik could I tell that on the unpatched servers by removing the "-P no" and getting the same result? (Also, this is from cron.daily, not crontab, not sure if that's ran in the same mode) – Peter Turner Nov 9 '15 at 16:09
  • Nevermind, with -P no, I guess the behavior is the same in interactive and non-interactive modes. – Mikel Nov 10 '15 at 0:52
  • Peter, did either of the answers solve your problem? – Jeff Schaller Dec 4 '15 at 15:16
  • @jeff not really, it would be nice to know if the need to the -P flag is just gone now. (FWIW, I've removed the -P flag on my build scripts, it only really mattered in cases where we were setting up machines that couldn't connect to our ntp servers and that's not gonna happen very often any more) – Peter Turner Dec 4 '15 at 15:24
2
+50

It appears that sntp was rewritten between version 4.2.4p8 (released 2009/12/8) and 4.2.6 (released 2009/12/12). The Changelog at (internal) version 4.2.5p201 indicates:

2009/08/13 Released by Harlan Stenn

* sntp: out with the old, in with the new.

...and that is the point at which the -P flag for sntp disappears.

The manpage for the new version has sample usage examples, one of which is: sntp -S ntpserver.somewhere, that corresponds to what the old -r flag was doing. It does not appear to take multiple "ntpserver.somewhere" options, so I don't know if there's any benefit to running it twice against different NTP servers.

1
ntpdate -b ntpserver

is usually used at boot times to set the time and does exactly what you need. Would it fit your needs?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.