3

So I wrote my father a neat little R script that pulls financial indicators on stocks, and outputs the info to a csv...

I would like to have it set up so that the script will run automatically once a day, skipping the weekends if possible. I looked around for awhile online and it seems as though the Mac "Automator" App is what I'm looking for.

However, after reading many guides and posts (like this one https://www.r-bloggers.com/how-to-source-an-r-script-automatically-on-a-mac-using-automator-and-ical/) I cannot get it to work...

In trying to replicate what this man did above I get the error that the first path is a directory; while the latter returns stuff like "cat: Rscript: No such file or directory"

So I was wondering if anyone could recommend either any good free software that will allow me to do what I would like, or how to run an R script from the /bin/bash shell

EDIT: The suggested solution isn't really answering my problem. The issue is making this as easy as possibly for my dad to run, that way he doesn't have to do anything, specifically use the terminal. Ideally I could just schedule a task that repeats every morning, but the cronR package requires Daemon, and the others are just command line tools

  • https://cran.r-project.org/web/packages/littler/index.html – M-- Jun 07 '17 at 14:44
  • Possible duplicate of [What's the best way to use R scripts on the terminal (bash)?](https://stackoverflow.com/questions/750786/whats-the-best-way-to-use-r-scripts-on-the-terminal-bash) – M-- Jun 07 '17 at 14:48
  • I have been using `crontab` in UNIX and never disappointed me – amonk Jun 07 '17 at 14:54
  • I hear good things about [cronR](https://github.com/bnosac/cronR), or you could just use cron directly. – alistaire Jun 07 '17 at 15:19

1 Answers1

0

I had a similar experience. I created an automator calendar alarm added a Execute AppleScript Action and used the following code:

on run {input, parameters}

try
    tell application "R"
        activate
        
        
        with timeout of 90000 seconds
            cmd "source(\"Dropbox/RScripts/CV19/liibre_coronabr.R\")"
            
        end timeout
    end tell
end try

return input

end run

When you save it, just choose the date and time for it to run and select the option to repeat everyday

That's it!

Ciso
  • 1
  • 2