I am trying to run an R script as a cronjob with a conda environment. Running the script from terminal works well with following script.sh
/opt/anaconda/anaconda3/envs/{env-name}/bin/Rscript '/ABSOLUTE_PATH/script.R'>> '/ABSOLUTE_PATH/script.log' 2>&1
However, when defining the job in crontab -e
as
30 14 * * * /ABSOLUTE_PATH/script.sh
Results in
Error: package or namespace load failed for 'tidyverse' in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/opt/anaconda/anaconda3/envs/admenv/lib/R/library/stringi/libs/stringi.so':
libicui18n.so.58: cannot open shared object file: No such file or directory
Execution halted
I have tried to run it as
/opt/anaconda/anaconda3/envs/{env-name}/bin/R '/ABSOLUTE_PATH/script.R'>> '/ABSOLUTE_PATH/script.log' 2>&1
source /opt/anaconda/anaconda3/bin/activate {env-name}; Rscript '/ABSOLUTE_PATH/script.R'>> '/ABSOLUTE_PATH/script.log' 2>&1
which all resulted in the same error as a cronjob.
Reinstalling packages in conda conda remove r-tidyverse; conda install -c r r-tidyverse
did not help.
Used R version is 3.6.2 and Anaconda 4.8.2. How could I solve this problem?