# Execute job with hooks

**URL:** <https://community.openpbs.org/t/execute-job-with-hooks/3339>\
**Category:** Users/Site Administrators\
**Created:** [October 27, 2022, 4:57pm UTC](https://community.openpbs.org/t/execute-job-with-hooks/3339 "2022-10-27T16:57:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vittocon](https://avatars.discourse-cdn.com/v4/letter/v/f05b48/32.png) [@Vittocon](https://community.openpbs.org/u/Vittocon)\
**Post date:** [October 27, 2022, 4:57pm UTC](https://community.openpbs.org/t/execute-job-with-hooks/3339/1 "2022-10-27T16:57:49Z")

</div>

Hi all,

I tried setting the “scheduling” (server attribute) to False and then running a job by using an Hook.  
I tried with a “queuejob” event hook with the following issue:

If I create a new job (just a simple one like ‘echo “sleep 10” | qsub’), it correctly handles the event but in the hook I cannot read the job.id attribute (it is an empty string) and then I cannot run a command like ‘qrun JOBID’.

Any suggestions?  
Thanks for helping

---

<div class="post-metadata">

**Author:** ![adarsh](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@adarsh](https://community.openpbs.org/u/adarsh)\
**Post date:** [October 28, 2022, 1:01pm UTC](https://community.openpbs.org/t/execute-job-with-hooks/3339/2 "2022-10-28T13:01:25Z")

</div>

> [@Vittocon](#):
>
> t correctly handles the event but in the hook I cannot read the job.id attribute (it is an empty string) and then I cannot run a command like

You would not get the jobid in queuejob hook event.  
It is also not a good idea or recommended to run pbs commands in the hooks.

---

<div class="post-metadata">

**Author:** ![adarsh](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@adarsh](https://community.openpbs.org/u/adarsh)\
**Post date:** [October 28, 2022, 1:26pm UTC](https://community.openpbs.org/t/execute-job-with-hooks/3339/3 "2022-10-28T13:26:10Z")

</div>

Please check the PBS Pro hooks guide , there is a table which decribes which attributes are settable / readable etc . JobID is created once the job is accepted and hence at the queuejob level it is not yet avaialble.
