(UP)

Typical script (one of the Viktor's many) that allows user to run a set of tasks or processes (e.g. named 'strt_e10') feeding different parameters into each task. It also stores useful information in a log-file that relates to the individual process. This is especially useful if one runs the same code simultaneously on many nodes and/or machines, as it allows user to identify PID and the hostname for the specific process. Extra lines can be added for the script to produce more information about the process.
(script, sample-out)

#!/bin/sh

filroot='zsup010'
execode='strt_e010'
filetemp='zzini010'
cutscrname=`echo $0 | awk '{print substr ($0,1,9)}'`
# 0.0 0.1 0.2 0.3
for percent in 0.4 0.5 0.6 0.7 0.8 0.9 1.0
do
case $percent in
0.0|1.0) Tstart=0.1
Tend=0.0 ;;
0.1) Tstart=0.5
Tend=0.1 ;;
0.9) Tstart=0.7
Tend=0.1 ;;
0.2|0.8) Tstart=0.7
Tend=0.1 ;;
*) Tstart=0.8
Tend=0.10 ;;
esac
filename=$filroot'_'$percent
hostn=`hostname`
echo $filename'\n'$Tstart'\n'$Tend'\n'$percent'\n' > $filetemp
echo '\n'---------------------------------------------------------'\n' > $filename.log
echo Present code is : >> $filename.log
echo - running on "'"$hostn"'" >> $filename.log
echo - called "'"$execode"'" >> $filename.log
echo - executed by script "'"$0"'" "("PID `ps -u $USER | grep "$cutscrname" | awk '{print $1}'`")" >> $filename.log
echo - creating output files with begining "'"$filename..."'" >> $filename.log
echo - started at `date` of $hostn time >> $filename.log
echo
echo '\n''\n'---------------------------------------------------------'\n' >> $filename.log
nohup $execode < $filetemp >> $filename.log
date >> $filename.log
done
rm $filetemp

#(c)2000 Viktor Yarmolenko, viktor.yarmolenko@physics.org


(UP)








  Science
Programming
Other Activities






©2002-2004 Viktor Yarmolenko