[R] Trouble with R and cronjobs

dstierman dstierman at micron.com
Wed Apr 3 01:51:48 CEST 2002


I am having problems with trying to run R from a crontab job. I have a
c-shell file that calls the R script. I get an error concerning the X11
display (see below). I have included the c-shell file and the output from
the crontab job. It appears that my DISPLAY environmental variable is not
set. Is that necessary, even when the output of the plot command is to a png
file? Can someone tell me how to fix this?
Thanks, Don

C-SHELL FILE:

#!/usr/bin/csh
source /u/dstierma/.cshrc
env
# /u/dstierma/bin/prbdata_bylot.pl
# /u/pesoft/bin/psums -lotlist -fab=3 -dbase=Y16A -30 >!
/u1yedh2/dstierma/probe/corr/Y16A.30
# /u/pesoft/bin/fabx @/u1yedh2/dstierma/probe/corr/Y16A.30 -fxt -sep='_'
-step=/3010-50 DUV PHOTO/ -ci~/%MACHINE%/ -exceldate -csv >!
/u1yedh2/dstierma/probe/corr/50duv.fxt
# /u/dstierma/bin/mergecsv2.pl 7 /u1yedh2/dstierma/probe/corr/50duv.fxt
/u1yedh2/dstierma/probe/corr/Y16A_scat.txt
# /usr/bin/cp merge.csv /u1yedh2/dstierma/probe/corr/y16a.txt
/usr/micron/sun4-sunos5.4/bin/R --no-save < /u/dstierma/bin/y16a_scat2.r

CRONTAB JOB OUTPUT:

Your "cron" job on unix1
/u/generic/bin/50duv.csh

produced the following output:

HOME=/u/dstierma
LOGNAME=dstierma
PATH=/usr/openwin/bin:/usr/openwin/bin/xview:/usr/X11/bin:/usr/openwin/demo:
/usr/openwin/demo/xview:/usr/micron/sun4/bin/xview:/usr/micron/sun4-sunos5.4
/bin/:/u/dstierma/bin:/u/dstierma/scripts:/usr/micron/sun4/bin:/usr/micron/b
in:/u/pesoft/bin:/u/test2end/bin:/u/summary/bin:/usr/local/bin:/usr/ucb:/usr
/bin:/bin:/u1yedh2/ye/cgi-bin:/amd/pefs2-f0/u7pefs2/dstierman/bin:/usr/micro
n/sun4-sunos5.5.1/bin:/u1yedh2/dstierma/bin:/u1yedh2/dstierma/cgi-bin:/u/kma
jor/programs:/etc:/usr/etc:/u1yedh2/ye/docs/java/graph/classes:/usr/5bin:/op
t/gnu/bin:/opt/gnu/sparc-sun-solaris2.6/bin:.:/vol/rs1/r5.3/rs1r5/sun4/bin/:
/vol/rs1/r5.3/rs1r5/solaris/bin/:/u/prbsoft/bin:/u/chirst/perl:/u/dstierma/b
in/ps2html:/u/pesoft/bin/proddram:/u/pesoft/bin/perl:/u/dstierma/bin/html2ps
-1.0b1:/u/fabya/bin:/usr/ccs/bin:/usr/newsprint/bin:/u1yedh2/dstierma/bin
SHELL=/usr/bin/sh
TZ=US/Mountain
PWD=/amd/pesfs2/u2pesfs2/dstierman
USER=dstierma
LD_LIBRARY_PATH=/u1yedh2/dstierma/lib:/u1yedh2/dstierma/lib/esda/lib:/u1yedh
2/dstierma/lib/oracle/product/8.0.5/lib:/u1yedh2/dstierma/lib/IXImotif/lib:/
u1yedh2/dstierma/lib/orbix/home/lib:/u1yedh2/dstierma/lib/esda/lib/IXI:/usr/
openwin/lib:/usr/X11/lib:/usr/lib/X11:/usr/micron/sun4-sunos5.6/lib
OPENWINHOME=/usr/openwin
PGPLOT_FONT=/usr/micron/sun4-sunos5.5.1/lib/pgplot/grfont.dat
ESDA_DIR=/u1yedh2/dstierma/bin/esda
LM_LICENSE_FILE=/u/dstierma/licenses/LIC_ESDA
HOST=yedh2
EXINIT=set redraw autoindent showmatch nowrapscan tabstop=8 shiftwidth=8

R : Copyright 2002, The R Development Core Team
Version 1.4.1  (2002-01-30)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type `license()' or `licence()' for distribution details.

R is a collaborative project with many contributors.
Type `contributors()' for more information.

Type `demo()' for some demos, `help()' for on-line help, or
`help.start()' for a HTML browser interface to help.
Type `q()' to quit R.

R is cool-> data<-read.csv("/u1yedh2/dstierma/probe/corr/y16a.txt")
R is cool-> cnames<-colnames(data)          # list of all the column names
in dataset
R is cool-> ncols<-length(cnames)           # number of columns in dataset
R is cool-> z<-as.vector(data$X3010.50DUVPHOTO.MACHINEPD.1)
R is cool-> x<-as.vector(data$X3010.50DUVPHOTO.DATE.0)
R is cool-> time<-strptime(x,"%d %b %Y %H:%M")
R is cool-> data$X3010.50DUVPHOTO.DATE.0<-as.POSIXct(time)
R is cool-> for(i in 9:dim(data)[2]) {      # number of columns of data
(data[1] is number of rows)
+	    y<-as.vector(data[cnames[i]])   
+	    an<-anova(lm(data[[cnames[i]]] ~
data$X3010.50DUVPHOTO.MACHINEPD.1))
+
png(file=paste("/u1yedh2/dstierma/probe/corr/Y16A_",cnames[i],".png",sep="")
, width=800, height=400, bg="white")
+	    par(las=c(2))
+	    par(oma=c(4,4,.2,.2))
+	    plot(data[[cnames[i]]] ~ data$X3010.50DUVPHOTO.DATE.0,xlab="\n50
DUV
Date",ylab=cnames[i],col=palette()[(as.numeric(factor(data$X3010.50DUVPHOTO.
MACHINEPD.1))%%6)+1],pch=((as.numeric(factor(data$X3010.50DUVPHOTO.MACHINEPD
.1))%%17)+1))
+	    par(las=c(1))
+	    title("Y16A DUV vs SCAT")
+
mtext(cnames[i],side=3,line=0,outer=TRUE,at=NA,adj=NA,cex=NA,col=1,font=NA)
+
legend.mar(legend=levels(factor(data$X3010.50DUVPHOTO.MACHINEPD.1)),col=pale
tte()[(1:length(levels(factor(data$X3010.50DUVPHOTO.MACHINEPD.1)))%%6)+1],pc
h=(1:length(levels(factor(data$X3010.50DUVPHOTO.MACHINEPD.1)))%%17)+1)
+	    zm<-tapply(data[[cnames[i]]], data$X3010.50DUVPHOTO.MACHINEPD.1,
mean)
+	    zmd<-tapply(data[[cnames[i]]],
data$X3010.50DUVPHOTO.MACHINEPD.1, median)
+	    zc<-table(data$X3010.50DUVPHOTO.MACHINEPD.1)
+	    mtext("P-val",1, outer=TRUE,adj = -0.08)
+	    mtext(round(an[1,5],digits=3),1, line=1, col="red",
outer=TRUE,adj = -0.08)
+	    mtext("X3010.50DUVPHOTO.MACHINEPD.1",1, line=-1,outer=TRUE, adj=
0)
+	    mtext("MEAN",1, line=1, outer=TRUE, adj= 0)
+	    mtext("MEDIAN",1, line=2, outer=TRUE, adj= 0)
+	    mtext("COUNT",1, line=3, outer=TRUE, adj= 0)
+	    for(a in 1:length(zm)) {
+	          mtext(labels(zm[a]),1, outer=TRUE, adj= a/10)
+	          mtext(round(zm[a],digits=2),1, line=1, outer=TRUE, adj=
a/10)
+	          mtext(round(zmd[a],digits=2),1, line=2, outer=TRUE, adj=
a/10)
+	          mtext(zc[a],1, line=3, outer=TRUE, adj= a/10)
+	      }
+	
+	}
Error in X11(paste("png::", filename, sep = ""), width, height, pointsize,
: 
	unable to start device PNG
In addition: Warning message: 
unable to open connection to X11 display`' 
Execution halted


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list