I am trying to schedule cron job for an R script.
I've read this question How do I set cron job and followed suggestions from first answer.
In the command line and put there a line
*/1 * * * * /usr/bin/Rscript /home/path/scriptTorun.R
The crontab file was saved under name:
The execution of an R script should be append to a text file after every scheduled time (1 minute) but it is not append or there might be no execution - somewhere is my fault.
Should I try to
chmod +x Rscript-name
Any suggestions? I'm new user of the ubuntu.
An R script looks like this:
library(rvest) library(dplyr) WP <- html("http://www.wp.pl/?bigDataModule=vowpallwabbit") Z_TYCH_LOSOWANIE <- html_nodes(WP, "[data-st-area=Sport] a[data-cluster], [data-st-area=Finanse] a[data-cluster], [data-st-area=Stylzycia] a[data-cluster], [data-st-area=Film] a[data-cluster], [data-st-area=Moto] a[data-cluster], [data-st-area=Kobieta] a[data-cluster], [data-st-area=Ciekawostki] a[data-cluster]") %>% html_attr( name = "href" ) DO_TYCH_LOSUJEMY <- html_nodes(WP, "[data-st-area=Glonews-mozaika] li:nth-child(7) a, [data-st-area=Glonews-mozaika] li:nth-child(6) a, [data-st-area=Glonews-mozaika-prawa] li:nth-child(1) a") %>% html_attr( name = "href" ) write.table( data.frame(all( DO_TYCH_LOSUJEMY %in% Z_TYCH_LOSOWANIE ), Sys.time()), quote=FALSE, append=TRUE, col.names=FALSE, row.names=FALSE, file = "/home/mkosinski//bigdataincontent//Boksy//Sprawdzenie logowania kafli/output.txt" )
I've changed the directory of an outputed file to a
/home/crontaband removed spaces from path to the Rscript and it worked fine