系统("timedatectl")"Failed to query server: Connection timed out"

system("timedatectl") "Failed to query server: Connection timed out"

我是 运行 RStudio 1.1.456 和 R 3.5.1,在装有 RHEL 7.6 的 AWS 服务器上(见下面的 sessionInfo)。我第一次(每次会话)调用 Sys.timezone() 时,出现错误:

> Sys.timezone()
Failed to query server: Connection timed out
[1] "America/Chicago"
Warning message:
In system("timedatectl", intern = TRUE) :
  running command 'timedatectl' had status 1

后续运行正常:

> Sys.timezone()
[1] "America/Chicago"

但是系统("timedatectl") 继续失败:

> system("timedatectl", intern = TRUE)
Failed to query server: Connection timed out
character(0)
attr(,"status")
[1] 1
Warning message:
In system("timedatectl", intern = TRUE) :
  running command 'timedatectl' had status 1

据我所知,在命令行中一切正常:

# timedatectl
      Local time: Fri 2019-02-22 11:18:14 CST
  Universal time: Fri 2019-02-22 17:18:14 UTC
        RTC time: Fri 2019-02-22 17:18:13
       Time zone: America/Chicago (CST, -0600)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: no
 Last DST change: DST ended at
                  Sun 2018-11-04 01:59:59 CDT
                  Sun 2018-11-04 01:00:00 CST
 Next DST change: DST begins (the clock jumps one hour forward) at
                  Sun 2019-03-10 01:59:59 CST
                  Sun 2019-03-10 03:00:00 CDT

# chronyc sources
210 Number of sources = 4
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* time.richiemcintosh.com       2   6   377    82   -405us[ -364us] +/-   33ms
^+ pool-173-71-69-215.cmdnn>     1   7   377    18  -1828us[-1828us] +/-   56ms
^+ vps5.ctyme.com                2   6   377    82   +972us[ +972us] +/-   66ms
^+ mirror1.sjc02.svwh.net        2   7   377    18  +2250us[+2250us] +/-   61ms

更新:直接从命令行中的 R 也可以正常工作。它只在 Rstudio 中失败。

我还应该尝试什么?我不明白为什么 system("timedatectl") 的行为与命令行中的 timedatectl 如此不同。

> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_3.5.1 tools_3.5.1    yaml_2.2.0  

已修复:

# grep timedated /var/log/audit/audit.log | audit2allow -M timedated
******************** IMPORTANT ***********************
To make this policy package active, execute:

semodule -i timedated.pp

# semodule -i timedated.pp