@Daniel: What exactly do you mean by “job’s path”? In the environment during QUEUEJOB, there are a few variables available, including j.Variable_List['PBS_O_HOME'] and j.Variable_List['PBS_O_WORKDIR']. PBS_O_HOME is the path to the requestor’s home directory on the submission host (not the execution host or server) and PBS_O_WORKDIR is the directory on the submission host in which the requestor ran qsub.
I recommend enabling debugging for the hook (set hook deny_home debug = true), which will result in some members and methods for the queuejob stage of the hook being written to /var/spool/pbs/server_priv/hooks/tmp (or equivalent path if your PBS_HOME is not /var/spool/pbs) on your PBS server. That information can be very useful for understanding what exactly is available to the hook when it runs. Everything is documented in the PBS Hooks guide, but not always easy to find.
My cluster has 2 network drives. The /home directory and the /scratch directory. /home is a non-clustered network drive (provided by a non-clustered file server). And /scratch is inside the cluster with inifiband, etc. Both of them are acessible in the entire cluster.
I would like to prevent users from running their jobs in this /home and only allow in /scratch.
We use a simulator that has a .dat input file. I would like to verify that this if .dat file is in /home/user/file.dat, the job should be deleted.
import os
import sys
import pbs
e = pbs.event()
j = e.job
who = str(e.requestor)
pbs.logmsg(pbs.LOG_DEBUG, "PBS_O_WORKDIR is = %s" % str(j.Variable_List['PBS_O_WORKDIR']))
user_home_path=os.path.join("/home",who)
pbs.logmsg(pbs.LOG_DEBUG, "USER HOME directory is is = %s" % user_home_path)
if user_home_path==str(j.Variable_List['PBS_O_WORKDIR']):
e.reject("Please submit the job or qsub from a different location other than home directory")