I have an R script code.R that has a certain probability of throwing an error. A layman example of such script could be:
if(runif(1,1,5)>2){
stop("Shift happens")
}else{cat("\nGreat success!")}
At this point, I am just manually calling the script several times in terminal until it has finished without throwing an error, like this:
Rscript /path_to_script/code.R
How can I run an Rscript in Linux until it has finished without throwing an error?