in reply to Apache causing R to crash

I think you're better off calling R yourself https://www.statmethods.net/interface/batch.html