cron job to execute r script not working

荒凉一梦 提交于 2020-01-03 03:06:08

问题


I am new to cron. I want to execute r script on regular basis using cron. I just added the job to crontab to check if it is working. But unfortunately, nothing is working. I wrote a test script and scheduled it for every 5 mins in cron job.

Here is test R script:

print('HI')

cronjob: 5 * * * * sudo Rscript /path/to/script/test.R

but when I execute it from terminal, it works fine.

terminal command: sudo Rscript /path/to/script/test.R

Please tell me if I am missing something here. I was trying to make it run for every 5 minutes.


回答1:


Change the permissions of the file /path/to/script/test.R and make sure, it has execution permissions to the user you are trying to submit the cronjob.

chmod 777 /path/to/script/test.R

Alternately, you can also try below mentioned ways also

Create a shell file (i.e., sample.sh) and place the following code in it. Rscript /path/to/script/test.R , and schedule the cron job as mentioned below.

5 * * * * /path/to/script/sample.sh



来源:https://stackoverflow.com/questions/33098235/cron-job-to-execute-r-script-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!