I would like Ubuntu to automatically synchronize my system clock with a timeserver at startup.
However, my PC isn't connected to the Internet until after I've logged in (plus 5 - 10 seconds for good measure).
How can I set it to do this?
This is done with NTP, for which instructions are available. Basically, you'll need to install an NTP daemon. There seem to be several choices available but the "standard" one is in the package
will get everything set up to synchronize with Ubuntu's NTP server.
EDIT: I missed "at startup." It's generally recommended to use ntpd to get continuous synchronization between your system and the server, but if you really only want to synchronize once, mfisch's answer seems to be what you're looking for.
If you go to "System->Administration->Time and Date", you will get a GUI to set the date/time.
An option is provided for using time servers. If you check it and NTP is not installed, it will ask if you want to install it. Just click "yes", and let it do its job :)
You can do this using at and ntpdate. at is probably already installed, but ntpdate may not be. (apt-get install ntpdate).
First create a small script that runs ntpdate, lets call it update_time.sh.
In your .bash_login file (which you may need to create) add this:
That should do what you want. You can change the delay that at uses to be 5 minutes, 10 minutes etc.
EDIT: I just realized that you'll need to be root to run ntpdate. You'll need to set the SUID bit on the update_time.sh script that I mentioned. You can do that by running this from the command (only needs to be run once):