Closed cawthm closed 5 years ago
That's how cron works. It starts the script from a different directory. You need to change your R code, Learn how to use environment variables to provide a path.
Thanks. For some reason, this isn't how it worked on mac os; ie the script wasn't portable to the new linux box w/ identical cronR setup steps.
cron runs the job as the user under which you scheduled the job. In no way this will be /home/me/my_script_folder, neither on mac or on linux
You are correct, having just tried to replicate on my mac. My script paths were slightly different on the two machines. Thank you for your help.
For some reason, my repository path isn't getting preserved when cron is run from a crontab set by this very useful package.
Eg, given a toy test script file:
The Rscript repository path: launch & log location dialog box looks correctly populated, eg it shows:
/home/me/my_script_folder
, wheretest_script.R
livesif I test it with run once test, eg:
nohup /usr/lib/R/bin/Rscript '/home/me/my_script_folder/test_script.R' >> '/home/me/my_script_folder/test_script.log' 2>&1 &
I see
/home/me/my_script_folder
in the log file, as expected.however, if I set a CRON job for test_script.R say, every minute
eg:
the cat'd path is just
/home/me
in the log file, dropping the project folder/my_script_folder
I'm running CronR 0.4.0 Under Rstudio 1.2.1335 With R 3.6.0 on Ubuntu 18.04 bash is default shell