![a data não mudaria no console](https://rvso.com/image/898932/a%20data%20n%C3%A3o%20mudaria%20no%20console.png)
Preciso alterar temporariamente a data para depurar um script e corro um problema inesperado:
root@xxx:/# LC_ALL=C date
Wed Jan 31 17:09:02 EET 2018
root@xxx:/# LC_ALL=C date -s "2018-01-10 17:09:30"
Wed Jan 10 17:09:30 EET 2018
root@xxx:/# LC_ALL=C date
Wed Jan 31 17:09:28 EET 2018
observação:Eu tenho uma ru_RU
localidade, então uso LC_ALL=C
para sua conveniência. Usar os comandos sem LC_ALL
alterar nada.
Imaginei que fiz algo errado com a sintaxe ou com a leitura man
incorreta, então usei as instruções deessetópico e não resolveu nada. tentativas de definir o hwclock para corresponder à data não resultaram em nada:
root@xxx:/# LC_ALL=C hwclock --systohc
root@xxx:/# LC_ALL=C hwclock --show
Wed Jan 31 17:18:17 2018 .451473 seconds
root@xxx:/# man hwclock
root@xxx:/# hwclock --set --date='2011-08-14 16:45:05'
root@xxx:/# LC_ALL=C hwclock --show
Sun Aug 14 16:45:09 2011 .389008 seconds
root@xxx:/# LC_ALL=C date
Wed Jan 31 17:21:07 EET 2018
Como posso alterar a data?
Sistema:
root@xxx:/# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.3 LTS"
ATUALIZAÇÃO para @Yaron
kovjr@xxx:~$ LC_ALL=C sudo date 120622432007.55
[sudo] password for kovjr:
Thu Dec 6 22:43:55 EET 2007
kovjr@xxx:~$ LC_ALL=C date
Wed Jan 31 18:19:23 EET 2018
Responder1
Conforme descritoaqui:
Ver hora
Para visualizar a data e hora atuais, o seguinte comando será suficiente
date
Definir tempo
Alterar a hora significa definir uma nova hora. Para definir a hora no Ubuntu (ou qualquer Linux), basta executar o seguinte comando
sudo date newdatetimestring
onde
newdatetimestring
deve seguir o formatonnddhhmmyyyy.ss
descrito abaixonn is a two digit month, between 01 to 12 dd is a two digit day, between 01 and 31, with the regular rules for days according to month and year applying hh is two digit hour, using the 24-hour period so it is between 00 and 23 mm is two digit minute, between 00 and 59 yyyy is the year; it can be two digit or four digit: your choice. I prefer to use four digit years whenever I can for better clarity and less confusion ss is two digit seconds. Notice the period ‘.’ before the ss.
Digamos que você queira definir o novo horário do seu computador para 6 de dezembro de 2007, 22:43:55, então você usaria:
sudo date 120622432007.55
Exemplo:
$ sudo date 120622432007.55
[sudo] password for xyz:
Thu Dec 6 22:43:55 IST 2007
$ date
Thu Dec 6 22:43:56 IST 2007
$