A quick post for how to set the date and time on Oracle Linux via the date
command. This post is more for my own documentation but hey, it might help others as well. To set a date or time you have to pass on the information via a formatted string to the date
command. I find calling date
twice, once for the date and once for the time, the easiest. The +%D
format option allows you to pass on the date as YYYY-MM-DD
, e.g. 2019-08-01 for the 1st of August 2019. To set the time, I use the +%T
format option to pass on the time as HH24:MI:SS
, e.g. 22:31:04.
date +%D -s 2019-08-01 date +%T -s 22:31:04
Format:
date +%D -s YYYY-MM-DD date +%T -s HH24:MI:SS