cronR | A simple R package for managing your cron jobs | Cron Utils library
kandi X-RAY | cronR Summary
kandi X-RAY | cronR Summary
cronR is a simple R package for managing your cron jobs.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of cronR
cronR Key Features
cronR Examples and Code Snippets
Community Discussions
Trending Discussions on cronR
QUESTION
I am trying to leave a node application with a cron job running on my laptop and it seems to work if I start the app not long before the job has to actually run. What I mean by this is if, for example, I set a job to run at 2:05 pm and I start the app at 2 pm, it runs fine, but if I start the app at 10 am, I don't know why, the job doesn't run (but the app IS still running) which is weird.
Does anyone know if locking my macbook (not turning the machine off, of course) or having the app running for a long time (say more than 1-2 hours) does something with node or macOS does something that may be the culprit of my job not running even if the app is still running?
It's weird because if I start the app just a bit before the job needs to run, everything runs fine, it's like if having the app running for a long time makes the job not work, but the app still runs.
I'm really confused about this, hope I made myself clear.
The code, just in case:
...ANSWER
Answered 2021-May-02 at 23:32Here is a cronjob scheduled to run every minute:
QUESTION
I am using cronR to schedule a report that gets sent out once every month. The report shouldn't be sent out on a weekend and should be sent somewhere between the 5th to 7th day of the month, depending on if that day is a weekend. So let's say 5th is a Saturday, and 6th is a Sunday, so the report should get sent out on Monday. Or if 5th is a Sunday, then it should send on the 6th. I'm not sure how possible this is-I also am using cronR so the expressions the package uses seem to be less flexible than other Linix/Unix commands I am seeing as solutions here. Any help would be appreciated.
...ANSWER
Answered 2021-May-05 at 17:01Most of the conditioning you talk of here (dom 5-7) is not directly supported by the cron scheduler. While I'm not fluent in the cronR
package itself (though I am comfortable with cron), I suspect the best path would be to always run it on each of days 5, 6, and 7, and have the R code check your day-of-week conditions.
For instance, try this function:
QUESTION
I have a dashboard living in a Shiny Server pro that shows different analysis. The data is coming from a long query that takes around 20 minutes to be completed.
In my current set up, I have a button that updates the data:
- queries new data
- transforms the data
- saves the data in a file .RData
- saves the data in a global object (using
data <<-
)
Just in case, outside the server and ui functions I have a statement that checks if data object exists. In case that does not exists, it reads the data from the .RData file instead of doing the query again.
Now I would like to update the data each Monday at 5:00pm (I do not want to open the app and push the button each Monday). I think that the best way to do it is using a cron job using cronR. The code will be located in the app.R outside the server and ui functions. Now I have the following questions:
- If I am using Shiny server pro how many times, the app, will create the cron job if it is located in the app.R outside the server and ui functions?
- How can I replace the object
data
in the shiny app? In such a way that if a user open the app on Monday after 5:00 pm the data will be in place, without the need of reading the .RData file and of course not doing the query again. - What is the best practice?
ANSWER
Answered 2021-Jan-21 at 15:04I cant't see your point 1. The app will not create the cron job if it is not named "global.R" or "ui.R" or "server.R", I think. Also, you don't have to put your code under the /srv/shiny-server/ directory.
For your point 2., check the reactiveFileReader
function from the shiny library. This function checks a file's last modified time and the file is re-read if changed
QUESTION
I am trying to run a Rscript using crontab with Rstudio closed and i am getting the following error in the log when the script is ran:
...ANSWER
Answered 2020-Oct-23 at 12:32function import is from the rio package. Your automated script fails because you did not load that package rio as in library(rio)
. This could not even have worked in RStudio itself neither if you did not load package rio.
QUESTION
I want to develop a cron job in Ubuntu
using R
with it cronR
package. That job would run on the first Sunday of every 3 months (this 3 should be a variable). However the cronR
package does not give any such functionality (as far as I know).
Can anyone give some pointer if it is possible to achieve this using cronR
package, or by any other means?
Thanks,
...ANSWER
Answered 2020-Feb-08 at 17:53You cannot do that with the semantics of basic Unix cron
. At least not as is.
What you can do, easily, is to have cron
call a script daily which then
- open a small 'state' memory file, can be csv or maybe easiest rds
- based on the last state, and current date and time, decide whether to run
- if it runs, update the 'state' file
QUESTION
Is it possible to include a "conditional import" in a package's DESCRIPTION file?
For example, I am developing a package which schedules system tasks. On Windows this is achieved with Task Scheduler and the taskscheduleR
package, on unix with the cronR
package. So intuitively it would be useful to do something like the following:
DESCRIPTION
ANSWER
Answered 2019-Oct-14 at 13:39I think this might be possible with a configure
shell script as described in Writing R Extensions. But I don't have experience doing that. You can also do platform-dependent stuff in your NAMESPACE files (that won't help here, but see the source of base package parallel for an example).
You could help your users by using that "The R and man subdirectories may contain OS-specific subdirectories named unix or windows." This allows you to have OS-specific code, which could then do the usual check for package availability.
E.g., in the windows subdirectory, you'd have something like:
QUESTION
ANSWER
Answered 2018-Oct-12 at 12:06If the first line of your #rstats script is wd <- here(), I will come into your lab and SET YOUR COMPUTER ON FIRE.
Learn how to use environment variables
QUESTION
A while back I was reading an article about improving project workflow. The advice was not to use setwd
or my computer would burn:
If the first line of your R script is
setwd("C:\Users\jenny\path\that\only\I\have")
I will come into your office and SET YOUR COMPUTER ON FIRE .
I started using the here
package and it worked great until I started to schedule scripts using cronR
. After asking this question my laptop was again threatened with arson:
If the first line of your #rstats script is wd <- here(), I will come into your lab and SET YOUR COMPUTER ON FIRE.
Fearing for my laptop's safety I started using the method suggested in the answer to get relative file paths:
...ANSWER
Answered 2018-Nov-22 at 17:03There are many ways to organize code and data for use with R. Given that the "arsonist" described in the OP has rejected at least two approaches for locating the project files in an R script, the best next step is to ask the arsonist how s/he performs this function, and adjust your code and file structures accordingly.
UPDATE: Since the "arsonists" appear to be someone who writes on Tidyverse.org (see Tidyverse article in OP) and an answer on SO (see additional links in OP), your computer appears to be relatively safe.
If you are sharing code or executing it with batch processes where the "user" is someone other than you, a useful approach is to place the code, data, and configuration under version control, and develop a runbook to explain how others can retrieve the components and execute them on another computer.
As noted in the comments to the OP, there's nothing wrong with here::here()
if its use can be made reliable through documentation in a runbook.
I structure all of my R code into Projects within RStudio, which are organized into a gitrepositories
directory. All of the projects can be accessed as subdirectories from the gitrepositories
directory. If I need to share a project, I make the project accessible to other users on GitHub.
In my R code I reference external files as subdirectories from the project root directory, such as ./data/gen01.csv
.
QUESTION
I've made a .R file with a plumber code. The file works fine on my local pc, it works also fine on my linux server. My only problem now is, that it's only local.
I need to be able to get the API over the server adress. The server also runs a cronR process which makes all the math and a shiny-app to display some graphs. All the math is stored into an cvs file and plumber should now get the last index and display this so I can use it from everywhere.
Are there any solutions?
Code:
...ANSWER
Answered 2017-Nov-16 at 18:56try
QUESTION
My R script works as intended when I run it on its own, but when I try to run it as a cron job, it keeps failing saying
...ANSWER
Answered 2017-Aug-05 at 06:14Sounds like you are trying to do something that can only be run in RStudio. Maybe one of you functions is trying to call a fucntion that can only be run in RStudio, for example one of the functions from here?
In that case, as suggested here, you can make the behavior of your script dependent on whether it's run in Rstudio or not. That can be achieved with the following line:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install cronR
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page