Friday, August 28, 2009

Set the system time in Linux

It is always a good idea to verify that the date and time are set correct on a computer system. Otherwise all of your logs will have the wrong time on them, for example. You can check the current system time by running the date command without any arguments, like so:
$ date
This will give you an output that looks something like this:
Fri Aug 28 10:53:48 EDT 2009
If the date is set incorrect, you can change it by running the date command as root with the new date and time as in argument. It will follow this format:
# date mmddhhmmyyyy.ss
For example, to set the date and time as August 28, 2009 at 10:53:48, you would type this:
# date 082810532009.48
If the year or seconds are correct you can leave off either or both of them. Also, keep in mind that this uses a 24 hour clock. So, if you wanted to set the date to August 28 at 1:00pm but didn't care about setting the seconds and the year was correct, you would type this:
# date 08281300

No comments:

Post a Comment