0

I am running OpenSUSE 15.4 and I am trying to set up a CRON job using crontab -e.

Inside my CRON tab I have the following:

*/1 * * * * /usr/bin/Rscript /run/media/matt/A34E-C6B8/folder/myRScript.R

So I give it the full path the where the RScript program can be found and then the location of the RScript I want to execute.

I check the system log files by running sudo tail -f /var/log/messages and I find this:

2023-05-04T16:41:03.034501+02:00 localhost systemd[1]: Started Time & Date Service.
2023-05-04T16:41:09.628633+02:00 localhost CRON[6807]: (matt) CMDEND (/usr/bin/Rscript /run/media/matt/A34E-C6B8/folder/myRScript.R)
2023-05-04T16:41:09.630489+02:00 localhost CRON[6807]: pam_unix(crond:session): session closed for user matt
2023-05-04T16:41:09.631608+02:00 localhost systemd[1]: session-c1005.scope: Deactivated successfully.

So, it looks like the cronjob is being run but being deactivated...

roaima
  • 107,089
  • 14
  • 139
  • 261
  • Does this answer your question - [How do I get the output of a cron script run from my home directory](https://unix.stackexchange.com/q/366827/100397)? – roaima May 04 '23 at 15:01
  • Does this answer your question - [Where does the output of `at` and `cron` jobs go](https://unix.stackexchange.com/q/40623/100397)? – roaima May 04 '23 at 15:01
  • By the way, `*/1` in the minutes field means "every minute, step by one minute" and is the same as `*` – roaima May 04 '23 at 15:05
  • Thanks! the `*/1` will be changed to 5 minutes. The RScript is actually on a memory pen. I am just not sure why the script does not execute from the CRON job but when I copy the file location and paste `RScript myRscriptfile.R` into the terminal it works. – user113156 May 04 '23 at 15:23
  • Take the answers in the two possible duplicates so you can at least see the error messages and/or output being produced. That will help you understand why your code isn't doing what you want it to do – roaima May 04 '23 at 16:13
  • Thanks! all worked! I added an edit to show the final solution. – user113156 May 04 '23 at 16:28
  • Pleased you've got a solution. But don't update your question with the answer -- instead either write an answer (that you can then accept tomorrow) or mark one of the suggested duplicates as a duplicate – roaima May 04 '23 at 16:37

1 Answers1

0

Adding >> /home/myuser/myscript.log 2>&1 to the end of the crontab line saves a log of the R code and now I see that I have the following error in the R code which is why I was getting no output!

Could not open chrome browser.
Client error message:
     Summary: UnknownError
     Detail: An unknown server-side error occurred while processing the command.
     Further Details: run errorDetails method
Check server log for further details.

Additionally, there is no log file for OpenSUSE, so manually creating it helped. ( https://certsimple.com/how-to-check-crontab-logs-in-suse-linux/ )

There is no specific crontab log for SUSE, but you can check your system logs to see if cron is running properly. To do this, open a terminal and type the following command: tail -f /var/log/messages You should see cron-related messages in the output. If you don’t see any messages, then cron is not running.


Taken from the question and moved to an answer

roaima
  • 107,089
  • 14
  • 139
  • 261