Both sides previous revisionPrevious revisionNext revision | Previous revision |
computing:batch [2017/12/23 11:40] – [Simple example] iwn | computing:batch [2018/09/11 09:51] (current) – [Storage element] iwn |
---|
===== Simple example ===== | ===== Simple example ===== |
| |
Say you have a [[computing:batch:scriptexample|python script]] in ''~/test'' that requires a CMSSW environment and some input ''foo'' and you would normally execute from the command line with | Say you have a [[computing:batch:scriptexample|python script]] in ''~/test'' that requires a ''CMSSW environment'' and some input ''foo'' and you would normally execute from the command line with |
| |
<code bash> | <code bash> |
# set CMSSW environment for script | # set CMSSW environment for script |
source /afs/cern.ch/cms/cmsset_default.sh | source /afs/cern.ch/cms/cmsset_default.sh |
cd /shome/myusername/phase2/CMSSW_5_3_24/src | cd $BASEDIR/CMSSW_5_3_24/src |
eval `scram runtime -sh` | eval `scram runtime -sh` |
| |
</code> | </code> |
| |
which you can run with | which you submit to run on the batch system with |
<code bash> | <code bash> |
qsub submitAnalysis.sh foo | qsub submitAnalysis.sh foo |
</code> | </code> |
| |
where ''submitAnalysis.sh'' is the name of the submission script. | |
| |
<wrap tip>__Note for beginners__</wrap>: ''shell'' variables are assigned //without// spaces, and can be accessed with the ''$'' sign. Arguments passed to a shell script are accessed with ''$1'', ''$2'', ... Example of basic syntax: | <wrap tip>__Note for beginners__</wrap>: ''shell'' variables are assigned //without// spaces, and can be accessed with the ''$'' sign. Arguments passed to a shell script are accessed with ''$1'', ''$2'', ... Example of basic syntax: |
MY_NAME=`whoami` | MY_NAME=`whoami` |
echo "$MY_NAME, you are here: `pwd`" | echo "$MY_NAME, you are here: `pwd`" |
| </code> |
| |
| <wrap tip>__Note for beginners__</wrap>: You need the ''CMSSW'' environment to have ''ROOT''. To get some release, e.g. ''CMSSW_5_3_24'', and initiate it do |
| <code bash> |
| source $VO_CMS_SW_DIR/cmsset_default.sh |
| cmsrel CMSSW_5_3_24 |
| cd CMSSW_5_3_24/src |
| cmsenv |
</code> | </code> |
| |
| |
| |
===== Queues ===== | ===== Queues ===== |
| |
* ''qw'' means waiting in queue, | * ''qw'' means waiting in queue, |
* ''E'' means in error state. | * ''E'' means in error state. |
| |
| More details on a job can be found with ''qstat -j <//jobid//>''. If your jobs are named, you can also use ''qstat -j <//jobname//>'' which might even contain a wildcard '*'. |
| ==== Change order of jobs ==== |
| |
| Change the order of submission of the jobs waiting in the queue with ''qalter -js <//jobshare//> <//jobid//>''. The default job share is ''0'' and any integer value (e.g. ''100'') will give the specified job a higher priority. The higher the value, the higher the priority. |
| |
| |
| ==== Delete ==== |
| |
| |
Furthermore jobs can be deleted with ''qdel <//jobid//>''. To delete //all// your jobs, use ''qdel -u <//username//>''. | Furthermore jobs can be deleted with ''qdel <//jobid//>''. To delete //all// your jobs, use ''qdel -u <//username//>''. |
qstat | grep wq | wc -l | qstat | grep wq | wc -l |
</code> | </code> |
| |
| To learn more details about one specific job, use ''qstat -j <//jobid//>''. In case it is in an error state, use ''qstat -explain E -j <//jobid//>''. |
===== Debugging ===== | ===== Debugging ===== |
| |
The T3 TWiki has a page with information on [[https://wiki.chipp.ch/twiki/bin/view/CmsTier3/HowToDebugJobs|debugging jobs interactively]]. | ==== Debugging jobs interactively ==== |
| |
| The T3 TWiki has a page with information on [[https://wiki.chipp.ch/twiki/bin/view/CmsTier3/HowToDebugJobs|debugging jobs interactively]] with the ''qlogin'' command: |
| <code bash> |
| qlogin -q debug.q -l hostname=t3wn22 -l h_vmem=400M |
| </code> |
==== Redirecting standard output and error streams === | ==== Redirecting standard output and error streams === |
If you want to isolate and save the standard output and the standard error streams (//stdout// and //stderr//) of your main script that would normally prompt in the Terminal window, you can redirect it as usual with ''>>'' and ''2>>'': | If you want to isolate and save the standard output and the standard error streams (//stdout// and //stderr//) of your main script that would normally prompt in the Terminal window, you can redirect it as usual with ''>>'' and ''2>>'': |
===== Storage element ===== | ===== Storage element ===== |
| |
You can also copy large output files to the storage element using the copy command **''lcg-cp''** or the recommended **''xrdcp''** from XROOTD, see [[https://wiki.chipp.ch/twiki/bin/view/CmsTier3/HowToAccessSe|How To Acces SE]]. | You can also copy large output files to the storage element using the copy command **''lcg-cp''** or the recommended **''xrdcp''** from XROOTD, see [[https://wiki.chipp.ch/twiki/bin/view/CmsTier3/HowToAccessSe|the TWiki on how To Acces SE]] or [[computing:storage|our page on the storage element]]. |
| |
<code> | <code> |
gfal-mkdir -p gsiftp://t3se01.psi.ch/`echo $SERESULTDIR | grep -o '/pnfs/psi.ch/.*'` | gfal-mkdir -p gsiftp://t3se01.psi.ch/`echo $SERESULTDIR | grep -o '/pnfs/psi.ch/.*'` |
</code> | </code> |
| |
===== Complete example ===== | ===== Complete example ===== |
| |
| |
If you want to split the events on several jobs you can do it manually as in the example [[computing:batch:splitjobexample|example_splitjobs.py]] and run it with **python**. In this example the command line inputs are maxEvents, firstEvent, inputFileNames and the seed for PU simulation. This works if you first made the CMSSW python script configurable. That can be done following this link [[https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideCommandLineParsing|Command line option parsing]]. | If you want to split the events on several jobs you can do it manually as in the example [[computing:batch:splitjobexample|example_splitjobs.py]] and run it with **python**. In this example the command line inputs are maxEvents, firstEvent, inputFileNames and the seed for PU simulation. This works if you first made the CMSSW python script configurable. That can be done following this link [[https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideCommandLineParsing|Command line option parsing]]. |
| |
| |
| ===== Monitoring busyness on the batch system ===== |
| |
| |
| |
| <wrap tip>__Protip__</wrap>:You can see how busy the batch system is due to other users with this command:<code bash> |
| qstat -u \* | tail -n +3 | awk '{if($5=="r"){r[$4]++} j[$4]++} END { for(n in j){ if(r[n]==""){ r[n]=0 } printf "%7s / %-5s - %s\n",r[n],j[n],n }}' |
| </code> |