날짜는 콘솔에서 변경되지 않습니다

날짜는 콘솔에서 변경되지 않습니다

한 스크립트를 디버깅하기 위해 날짜를 일시적으로 변경해야 하는데 예상치 못한 문제가 발생했습니다.

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

메모:로케일이 있으므로 귀하의 편의를 위해 ru_RU사용합니다 . 아무 것도 변경 LC_ALL=C하지 않고 명령을 사용합니다 LC_ALL.

구문에 문제가 있거나 man잘못 읽는다고 생각해서 다음 지침을 사용했습니다.이것스레드를 사용해도 아무것도 해결되지 않았습니다. 날짜와 일치하도록 hwclock을 설정하려고 시도했지만 결과는 없습니다.

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

날짜를 어떻게 변경할 수 있나요?

체계:

root@xxx:/# cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.3 LTS"

@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

답변1

설명한대로여기:

시간 보기

현재 날짜와 시간을 보려면 다음 명령으로 충분합니다.

date

시간 설정

시간을 변경한다는 것은 새로운 시간을 설정한다는 의미입니다. Ubuntu(또는 Linux)에서 시간을 설정하려면 다음 명령을 실행하세요.

sudo date newdatetimestring

아래 설명된 newdatetimestring형식을 따라야 합니다 .nnddhhmmyyyy.ss

nn 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.

컴퓨터의 새로운 시간을 2007년 12월 6일, 22:43:55로 설정하고 싶다면 다음을 사용합니다.

sudo date 120622432007.55

예:

$ 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
$

관련 정보