1 |
janjust |
2553 |
#!/bin/bash |
2 |
|
|
# WLCG Worker Node Environment |
3 |
|
|
# PBS Prologue script: clean up the $JOBFEATURES file` |
4 |
|
|
# |
5 |
|
|
# Config settings for the wlcg-wn-env scripts |
6 |
|
|
# |
7 |
|
|
# Copyright (c) 2012 by |
8 |
|
|
# Jan Just Keijser (janjust@nikhef.nl) |
9 |
|
|
# Nikhef |
10 |
|
|
# Amsterdam |
11 |
|
|
# The Netherlands |
12 |
|
|
|
13 |
|
|
# a PBS user prologue script is called with up to 7 parameters, out of which we |
14 |
|
|
# are only interesed in $1 and $5: |
15 |
|
|
# $1 = jobid |
16 |
|
|
# $5 = job specifics such as cputime and walltime |
17 |
|
|
# e.g. cput=04:00:00,neednodes=1,nodes=1,pvmem=400mb,walltime=04:00:00 |
18 |
|
|
|
19 |
|
|
# overrule any environment variable setting with the parameter supplied to the script |
20 |
|
|
PBS_JOBID=$1 |
21 |
|
|
|
22 |
|
|
# Get the configuration setting from the /etc/wlcg-wn-env.conf file |
23 |
|
|
eval "JOBFEATURES=`sed -n '/^jobfeatures/s/^jobfeatures *= *\(.*\)/\1/p' /etc/wlcg-wn-env.conf 2> /dev/null`" |
24 |
|
|
# fallback if setting is missing |
25 |
|
|
JOBFEATURES=${TMPDIR:-/tmp}/jobfeatures.${PBS_JOBID} |
26 |
|
|
|
27 |
|
|
|
28 |
|
|
jobstart=`date --utc` |
29 |
|
|
cpu_lim=`echo "$5" | cut -d, -f1 | cut -d= -f2 | awk -F: '{ cpu_lim=3600*$1+60*$2+$3 ; printf "%d\n", cpu_lim }'` |
30 |
|
|
wall_lim=`echo "$5" | cut -d, -f5 | cut -d= -f2 | awk -F: '{ wall_lim=3600*$1+60*$2+$3 ; printf "%d\n", wall_lim }'` |
31 |
|
|
|
32 |
|
|
echo "jobstart=${jobstart}" > ${JOBFEATURES} |
33 |
|
|
echo "cpu_limit=${cpu_lim}" >> ${JOBFEATURES} |
34 |
|
|
echo "wall_limit=${wall_lim}" >> ${JOBFEATURES} |
35 |
|
|
|