6629 |
07 Mar 22 |
nicklas |
#!/bin/bash |
6614 |
28 Feb 22 |
nicklas |
2 |
## |
6614 |
28 Feb 22 |
nicklas |
## This script is used to start a job in the background |
6614 |
28 Feb 22 |
nicklas |
## and return the JOB_ID to the caller. |
6614 |
28 Feb 22 |
nicklas |
## Options/parameters for the job are expected to be |
6614 |
28 Feb 22 |
nicklas |
## in the file that is given as the only parameter. |
6614 |
28 Feb 22 |
nicklas |
7 |
## |
6614 |
28 Feb 22 |
nicklas |
8 |
|
6614 |
28 Feb 22 |
nicklas |
## JOB ID is the process id of the current script |
6614 |
28 Feb 22 |
nicklas |
10 |
export JOB_ID=$$ |
6614 |
28 Feb 22 |
nicklas |
11 |
export JOB_OPTIONS=$1 |
6614 |
28 Feb 22 |
nicklas |
12 |
|
6614 |
28 Feb 22 |
nicklas |
## Read other parameters |
6614 |
28 Feb 22 |
nicklas |
14 |
source ${JOB_OPTIONS} |
6614 |
28 Feb 22 |
nicklas |
15 |
|
6614 |
28 Feb 22 |
nicklas |
## Write status information |
6639 |
11 Mar 22 |
nicklas |
17 |
echo "Name: ${JOB_NAME}" > ${STATUS_FILE} |
6614 |
28 Feb 22 |
nicklas |
18 |
echo "Host: `hostname`" >> ${STATUS_FILE} |
6614 |
28 Feb 22 |
nicklas |
19 |
echo "Submitted: `date +'%Y-%m-%d %T'`" >> ${STATUS_FILE} |
6614 |
28 Feb 22 |
nicklas |
20 |
|
6614 |
28 Feb 22 |
nicklas |
## Start job.sh in the background |
6639 |
11 Mar 22 |
nicklas |
22 |
nohup /bin/bash ${WD}/run.sh > ${SGE_STDOUT_PATH} 2> ${SGE_STDERR_PATH} & |
6614 |
28 Feb 22 |
nicklas |
23 |
|
6614 |
28 Feb 22 |
nicklas |
## Returns the job id to the submitter |
6614 |
28 Feb 22 |
nicklas |
25 |
echo ${JOB_ID} |