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.
I typed
crontab -e
In the command line and put there a line
*/1 * * * * /usr/bin/Rscript /home/path/scriptTorun.R
The crontab file was saved under name: /tmp/crontab.6eWd50/crontab
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" )
EDIT
I've changed the directory of an outputed file to a /home/crontab
and removed spaces from path to the Rscript and it worked fine
2> /tmp/cronerror
to the end of yourcron
line. That will print any error messages into the file/tmp/cronerror
. If any errors are printed, please [edit] your question and include them. – terdon Mar 31 '15 at 11:45*/1
is superfluous:*
already means every minute. – Jos Mar 31 '15 at 11:52