-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathunix_submit
executable file
·59 lines (58 loc) · 1.83 KB
/
unix_submit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
#
# file: /usr/local/mdsplus/bin/unix_submit.sh
#
# shell script to spawn a batch job for automatic intershot analysis.
#
# called by unix_submit.fun
#
# procedure:
# build a log file name from the base file name
# (logs go to /var/mdsplus/log)
# insert a status line for this shot
# invoke the job with the shot number as $1 redirecting stdout and err
# to the end of the log file
# insert a done status line for this shot
#
# param 1 = file-spec of batch job
# param 2 = shot number
# param 3 = PRE (create lock file only)
# param 3 = CONNECTFAIL (delete lock file)
#
FILE=`basename $1 ".sh"`
if [ "x$MDS_LOGS" = "x" ]; then
MDS_LOGS="/var/log/mdsplus";
fi
if [ -d "$MDS_LOGS" -a -w "$MDS_LOGS" ]; then
LOG="$MDS_LOGS/$FILE.$2.log"
CUMULATIVE_LOG="$MDS_LOGS/$FILE.log"
if [ "$3" = "CONNECTFAIL" ]
then
rm -f ${LOG}.lock
echo ">>>>>>>>>>>>>>>>>>>>> $2 >>>>>>>>>>>>>>>>>>>>" >> $CUMULATIVE_LOG
echo `date`: Job $1 --- Connection to host $4 failed. >> $CUMULATIVE_LOG
echo "<<<<<<<<<<<<<<<<<<<<< $2 <<<<<<<<<<<<<<<<<<<<" >> $CUMULATIVE_LOG
exit 0
elif [ -e ${LOG}.lock ]
then
if [ "$3" = "PRE" ]; then exit 0; fi
elif [ "$3" = "PRE" ]
then
touch ${LOG}.lock
exit 0;
else
lockfile "$LOG.lock"
fi
touch $MDS_LOGS/pid/`hostname`-$$ 2>/dev/null
echo ">>>>>>>>>>>>>>>>>>>>> $2 >>>>>>>>>>>>>>>>>>>>" >> $LOG
echo `date`: Job $1 beginning on `hostname` >> $LOG
/usr/bin/time -a -f "Elapsed %E\tUser %U\tSystem %S" -o $LOG $1 $2 < /dev/null >>$LOG 2>&1
echo "<<<<<<<<<<<<<<<<<<<<< $2 <<<<<<<<<<<<<<<<<<<<" >> $LOG
echo " " >> $LOG
cat $LOG >> $CUMULATIVE_LOG
rm -f $LOG
rm -f "$LOG.lock"
rm -f $MDS_LOGS/pid/`hostname`-$$
else
echo "Directory MDS_LOGS ($MDS_LOGS) must exist and be writeable"
fi