Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm running RStudio 1.1.456 with R 3.5.1 on an AWS server with RHEL 7.6 (see sessionInfo below). The first time (per session) that I call Sys.timezone(), I get an error:

> 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

Subsequent times it runs fine:

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

But system("timedatectl") continues to fail:

> 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

From the command line, everything is fine as far as I can tell:

# 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

Update: It also works fine directly from R in the command line. It ONLY fails in Rstudio.

What else should I try? I don't understand why system("timedatectl") is behaving so different from timedatectl from the command line.

> 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  
like image 739
Jon Harmon Avatar asked Feb 22 '19 17:02

Jon Harmon


1 Answers

This fixed it:

# 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
like image 200
Jon Harmon Avatar answered Oct 24 '22 09:10

Jon Harmon