0

Trying to run an 'R' script at 00:30 every day. The script is located in /home/username/Desktop/folder/runnow.r and which Rscript reveals that the absolute path to binary Rscript is /usr/bin/Rscript. The crontab entry that I made was using the crontab -e command and then inserting the line:

38 14 * * * /usr/bin/Rscript /home/username/Desktop/folder/runnow.r

Time right now is 14:36 of course. And I wait 5 minutes to see if a CSV file is created in my home folder. Since the R script runnow.r has instructions to process some data and then create a CSV file in the home folder.

But there's no CSV file in my home folder. When I manually run this script (without using cron), it does create a CSV in my home folder. So I know there's nothing wrong with the script. I am using absolute paths everywhere and I have even tried restarting the crond using service crond restart. However, no luck. Is this a privileges issue? Does crond not have enough privileges to create a CSV in my own home folder?

EDIT: NEW OBSERVATION

If I change the line to * * * * * /usr/bin/Rscript /home/username/Desktop/foldername/runme.r instead of specifying the exact time, it does create the right CSV file in the right location. So * * * * * works and 54 13 * * * doesn't. Why?

learnerX
  • 121
  • 4

1 Answers1

2

I figured it out after the last observation I made regarding time. This is going to make me look silly, but I had gotten the time wrong. I'm testing this cronjob in a virtual machine that has a time different from my host machine. I was scheduling the job in the virtual machine, and looking at the time on my host machine. Both times being different meant that script didn't execute on the time I expected it too.

learnerX
  • 121
  • 4
  • Yet another argument for UTC everywhere! – chicks Aug 25 '16 at 20:03
  • `This is going to make me look silly, but I had gotten the time wrong` Never be ashamed to make mistakes. You figured out what was wrong and I bet you are unlikely to make that mistake again. Thumbs up emoji. – Mark Riddell Aug 25 '16 at 20:10