$ cat inst/templates/sge.tmpl
## Shell:
#$ -S /bin/bash # Run this as a bash script (required)
## Job name:
#$ -N <%= if (exists("job.name", mode = "character")) job.name else job.hash %>
## Merge standard error and output:
#$ -j y
## Direct streams to logfile:
#$ -o <%= log.file %>
## Tell the queue system to use the current directory
## as the working directory
#$ -cwd
## Use environment variables
#$ -V
## Resources needed:
<% if (exists("resources", mode = "list") && length(resources) > 0) {
## Example:
## sge_options <- c("-pe smp 2", "-l mem_free=1G", "-R yes")
## plan(batchtools_sge, resources = list(asis = sge_options))
cat(sprintf("#$ %s\n", resources[["asis"]]))
} %>
# For troubleshooting, in case there are errors
date
hostname
which Rscript
Rscript --version
Rscript -e ".libPaths()"
echo "Command: Rscript -e 'batchtools::doJobCollection("<%= uri %>")' ..."
Rscript -e 'batchtools::doJobCollection("<%= uri %>")'
res=$?
echo " - exit code: ${res}"
echo "Command: Rscript -e 'batchtools::doJobCollection("<%= uri %>")' ... done"
## For troubleshooting, in case there are errors
qstat -j "$JOB_ID"
## Relay the exit code from Rscript
exit "$res"