I need a help to write a hook. I would like to delete a job if job’s path is something like /home/username, eg.
I have read the PBS hooks guide, but I’am in dought on how to do it.
I think that I need a pre-execution hook like this:
create hook deny_home
import hook deny_home application/x-python default /hooks/deny_home_script.py
set hook deny_home event = queuejob
set hook deny_home order = 2
set hook deny_home alarm = 60
and the python script content is:
e = pbs.event()
j = e.job
if '/home' in j.Submit_arguments:
e.reject("Performing tasks in home directory is not allowed")
e.reject(“Performing tasks in home directory is not allowed”)
Is it right?
@Daniel: What exactly do you mean by “job’s path”? In the environment during QUEUEJOB, there are a few variables available, including
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
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.
Hi @gabe, how are you doing?
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.
@daniel, please try this queuejob hook
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']))
pbs.logmsg(pbs.LOG_DEBUG, "USER HOME directory is is = %s" % user_home_path)
e.reject("Please submit the job or qsub from a different location other than home directory")
The solution works perfectly!!! My users are going crazy! =D
Nice one Thank you @daniel