date
- date -d '@0' で epoch時刻を表示し、date -s '@0' で epoch時刻 を設定する、はずだが dateコマンドはエラーを返す。
- しかしなぜか epoch +数時間後であれば設定できる。
[root@centos8-localdomain work]# export TZ=UTC [root@centos8-localdomain work]# date -d '@0' Thu Jan 1 00:00:00 UTC 1970 [root@centos8-localdomain work]# date -s '@0' date: cannot set date: Invalid argument Thu Jan 1 00:00:00 UTC 1970 [root@centos8-localdomain work]# date -d '@32400' Thu Jan 1 09:00:00 UTC 1970 [root@centos8-localdomain work]# date -s '@32400' date: cannot set date: Invalid argument Thu Jan 1 09:00:00 UTC 1970 [root@centos8-localdomain work]# date -s '@42400' date: cannot set date: Invalid argument Thu Jan 1 11:46:40 UTC 1970 [root@centos8-localdomain work]# date -s '@52400' date: cannot set date: Invalid argument Thu Jan 1 14:33:20 UTC 1970 [root@centos8-localdomain work]# date -s '@62400' date: cannot set date: Invalid argument Thu Jan 1 17:20:00 UTC 1970 [root@centos8-localdomain work]# date -s '@72400' date: cannot set date: Invalid argument Thu Jan 1 20:06:40 UTC 1970 [root@centos8-localdomain work]# date -s '@82400' Thu Jan 1 22:53:20 UTC 1970 [root@centos8-localdomain work]# date Thu Mar 18 14:31:06 UTC 2021 [root@centos8-localdomain work]# date -s '@82400' Thu Jan 1 22:53:20 UTC 1970 [root@centos8-localdomain work]# date Thu Jan 1 22:53:24 UTC 1970
- エラーは settimeofday システムコールで発生している。
- 原因は不明
settimeofday({tv_sec=0, tv_usec=0}, NULL) = -1 EINVAL (Invalid argument)
参考になるかもしれない Why cannot I set the date of my GNU/Linux machines to the Epoch? - Unix & Linux Stack Exchange https://unix.stackexchange.com/questions/533393/why-cannot-i-set-the-date-of-my-gnu-linux-machines-to-the-epoch
pidstat
- pidstatはプロセスIDごとにCPU使用率を表示する。
- CPU列に表示するCPUは最後に実行したプロセッサ番号である。
https://github.com/sysstat/sysstat/blob/master/pidstat.c#L452
rc = sscanf(start, "%*s %*d %*d %*d %*d %*d %*u %llu %llu" " %llu %llu %llu %llu %lld %lld %*d %*d %u %*u %*d %llu %llu" " %*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %*u" " %*u %u %u %u %llu %llu %lld\n", &pst->minflt, &pst->cminflt, &pst->majflt, &pst->cmajflt, &pst->utime, &pst->stime, &pst->cutime, &pst->cstime, thread_nr, &pst->vsz, &pst->rss, &pst->processor, &pst->priority, &pst->policy, &pst->blkio_swapin_delays, &pst->gtime, &pst->cgtime);
- /proc/pid/stat は procファイルシステムの stat の実装を見ると、task_cpu(task) を返す。
https://github.com/torvalds/linux/blob/master/fs/proc/array.c
seq_put_decimal_ll(m, " ", task_cpu(task));