Hello!

I am having issues trying to plot to a ong (or jpg)  when the R-code in a
bash script is executed from cron.

I can generate a pdf file, but when I try to write to a png, the file is
created, but nothing is written. If I execute the bash script from my
console, everything works file. Any ideas?

In my cron I have SHELL=/bin/bash - otherwise /bin/shell is used and the
folowing enery, so example is executed every minute
* * * * * [path]/example.sh

I am running
R version 2.4.1 (2006-12-18)

Here's a minimal example - two files one R-script ('example.r') and one
bash-script ('example.sh')

example.r
# Example R-script
x <- c(1:10)
y <- x^2
png(file="example2.png")
#pdf(file="example2.pdf")
plot(x,y)
graphics.off()

example.sh
#/bin/bash
#
# Hello world is written to exhotext every time cron executes this script
echo "Hello world" > echotext
# This works, but not when executed from cron
n=`R --save < example.r`
# using exec as in `exec R --save < example.r` dosent work with cron either
# This also works, but nothing is written to the png when executed from cron
R --save <<RSCRIPT
x <- c(1:10)
y <- x^2
png(file="example2.png")
#pdf(file="example2.pdf")
plot(x,y)
graphics.off()
#dev.off() dosent work at all when executed from cron
RSCRIPT

Thanks
Ulrik

	[[alternative HTML version deleted]]

