I am trying to schedule my R script using cron, but it is not working. It seems R can not find packages in cron. Anyone can help me? Thanks. The following is my bash script # source my porfile . /home/winie/.profile # script.R will load packages R CMD BATCH /home/script.R -- View this message in context: http://r.789695.n4.nabble.com/Schedule-R-script-using-cron-tp4550729p4550729.html Sent from the R help mailing list archive at Nabble.com.
On 12.04.2012 03:51, winie wrote:> I am trying to schedule my R script using cron, but it is not working. It > seems R can not find packages in cron. Anyone can help me? Thanks. > > The following is my bash script > > # source my porfile > . /home/winie/.profile > # script.R will load packages > R CMD BATCH /home/script.RMaybe it does not call the R version your expect? Or you have not set the pat to the library given the packages are not installed in R's main library in R_HOME? Uwe Ligges> > -- > View this message in context: http://r.789695.n4.nabble.com/Schedule-R-script-using-cron-tp4550729p4550729.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
>>>>> winie <winiebook at gmail.com> >>>>> on Wed, 11 Apr 2012 18:51:28 -0700 writes:> I am trying to schedule my R script using cron, but it is not > working. It seems R can not find packages in cron. Anyone can help me? > Thanks. > The following is my bash script > # source my porfile > . /home/winie/.profile > # script.R will load packages > R CMD BATCH /home/script.R This has almost nothing to with R, but with running scripts in cron. On the systems, I've been using, the default shell cron uses is very simple, e.g., PATH = /usr/bin:/bin , so I assume that's why you source your (bash ?) profile, > . /home/winie/.profile above. But that may not be sufficient; there are other settings, missing in the simple "cron" environment, that your .profile does not fix up, such as LD_LIBRARY_PATH, R_LIBS, R_PROFILE, ... I would add a line to "your bash script" env > /tmp/cron_env_$$ after the ". /home/winie/.profile" line, and see how that (cron_env_... file) differs from what you get when you type 'env' in a regular interactive shell where (I assume) your 'R CMD BATCH ...' works correctly. Hoping that helps, Martin