[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#40220: date command set linux epoch time failed
From: |
shy |
Subject: |
bug#40220: date command set linux epoch time failed |
Date: |
Wed, 25 Mar 2020 09:40:13 +0800 (CST) |
Hi all:
I use command date -s "1970-01-20 00:00:00" to set date, but it failed.
there is error message "date: can't set date: Invalid argument".
It's UTC time and no timezone.
I test with stime or settimeofday to set seconds 0, they are all have the
problem.
1. I use buildroot-2013.05, the busybox is in 1.21.1, the linux kernel is in
version 4.4.39.
# date -s "1970-01-20 00:00:00"
Tue Jan 20 00:00:00 UTC 1970
# date -R
Tue, 20 Jan 1970 00:00:03 +0000
# date -s "1970-01-01 00:00:00"
date: can't set date: Invalid argument
Thu Jan 1 00:00:00 UTC 1970
2. I test in ubuntu version 14.04.1.
shy@ubuntu:/etc$ sudo date -s "2020-03-01 00:00:00"
Sun Mar 1 00:00:00 UTC 2020
shy@ubuntu:/etc$ date -R
Sun, 01 Mar 2020 00:00:03 +0000
shy@ubuntu:/etc$ sudo date -s "1970-01-01 00:00:00"
date: cannot set date: Invalid argument
Thu Jan 1 00:00:00 UTC 1970
shy@ubuntu:/etc$ uname -a
Linux ubuntu 4.4.0-142-generic #168~14.04.1-Ubuntu SMP Sat Jan 19 11:26:28 UTC
2019 x86_64 x86_64 x86_64 GNU/Linux
3.When set date command, the busybox uses function "stime" to set time, I use
stime to set time around linux epoch time,
but the stime seems not work well.
int ret = 0;
time_t time = 20;
ret = stime(&time);
printf("ret %d %d\r\n",ret, errno);
perror("stime:");
and the results are as follows:
ret -1 22
stime:: Invalid argument
Best regards!
- bug#40220: date command set linux epoch time failed,
shy <=