Ntp and networkmanager aren’t friends

On my Opensuse box I’ve setup ntp to synchronize time, but because I’m using networkmanager and since Knetworkmanager doesn’t log me on to the network until KDE is up and running, ntp end up not finding any servers during boot and just goes to sleep.
A really easy / lazy fix to the problem is to simply restart the ntp service after logging on to Kde, but then again I need to be root to restart ntp.
I decided giving myself sudo rights with no password to the ntp service and put a script in Kde’s autostart folder.

Setup sudo rights in /etc/sudoers by issuing:

# visudo /etc/sudoers

Add the line:

 [your_username]    ALL = (ALL) NOPASSWD: /etc/init.d/ntp restart

Now your user can run the command:

$ sudo /etc/init.d/ntp restart

which you could but in a script in ~.kde4/Autostart/restart_ntp.sh and the problem is solved 🙂

Note: sudo is quite picky about the command specified. In the line above my user can run the command as specified, but if I try to run for instance

$ sudo service ntp restart

which basically is the same command, sudo won’t let me because that’s not the command I specified.