1

I've tried running this a few different ways, but at the moment I have my crontab file as

MAILTO=email1@gmail.com,email2@gmail.com

40 10 * * * /home/me/my_script.sh

This my_script.sh is a shell script that runs an R script.

#!/bin/sh

/usr/bin/Rscript /home/me/stuff/daily_routine.R >> /home/me/stuff/output/outputstuff

If I just go to the terminal and run the following, though it works:

/home/me/my_script.sh

This R script downloads data from the internet. Could that be it? I've tried to include full paths everywhere, so I'm not sure that it's the PATH variable.

I never configured anything related to email, so I'm not sure how it is supposed to send it. Maybe that's it.

Edit:

It turned out that I had never installed and configured anything to send email. I ended up fixing the issue by installing and configuring ssmtp to send emails by using my gmail account. It took me a lot of fiddling around, so I'm not sure if I have a postable solution.

Also, I am not sure whether I should delete this question or keep it up. All of the cron tutorials I found are misleading--none of them mentioned having to do this.

Taylor
  • 1,797
  • 4
  • 26
  • 51
  • It's very difficult to say from the information you've provided. Try adding `2>&1` to the end of the crontab command so that you also append error messages to your output file. Also add print messages inside your R script so that you can start to narrow down if/where the interpreter is failing to execute the script. Often this sort of issue has either to do with file/directory permissions or with the execution path being followed. – cmaher Sep 29 '17 at 03:17
  • @cmaher the R script does have a few print statements and nothing gets printed. But yeah I'll try that and make some changes to the question. Thanks. – Taylor Sep 29 '17 at 03:45
  • When you run the R script manually does it complete without error? Does anything get printed? – beigel Sep 29 '17 at 04:28
  • @beigel yes, and everything shows up. – Taylor Sep 29 '17 at 04:32
  • Do you get any error messages/emails? They often indicate something less-unclear, such as `Rscript: command not found` or something similar. – r2evans Sep 29 '17 at 04:43
  • @r2evans no email no. And when I redirect the output no output either. – Taylor Sep 29 '17 at 15:17
  • It is quite possibly related to `PATH`, which has been [answered](https://stackoverflow.com/questions/2388087/how-to-get-cron-to-call-in-the-correct-paths) [several](https://stackoverflow.com/questions/10129381/crontab-path-and-user) [times](https://unix.stackexchange.com/questions/148133/how-to-set-crontab-path-variable). Do you receive emails for other non-`Rscript` cron entries with the same `MAILTO`? – r2evans Sep 29 '17 at 15:25
  • @r2evans see edit. – Taylor Sep 30 '17 at 03:00

0 Answers0