'Can anyone help me with this crontab?

We want to download the stock price of Tesla every day, using the package "quantmod" in R. We managed to write the function that downloads the last available stock and store it in a database in SQL: indeed, if we run the function manually, we can see the table with the stock price of today. However, if we let it run alone with crontab, it doesn't work: we set it up on the 14th, and as of today, it only downloaded the price of the 18th. This is how we set up the crontab:

# m h dom mon dow user1 command

59 23 * * 1-5 /usr/bin/Rscript...

Anyone? I'm sure it's a stupid mistake but it doesn't work.



Solution 1:[1]

You can schedule cron jobs with package cronR.

library(cronR)

f <- "/home/project/daily.R"
cmd <- cron_rscript(f)
cmd <- cron_add(
  command = cmd,
  frequency = "59 23 * * 1-5"
)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rui Barradas