# Error using the "run\_epilogue\_shell hook "

**URL:** <https://community.openpbs.org/t/error-using-the-run-epilogue-shell-hook/3806>\
**Category:** Users/Site Administrators\
**Created:** [March 12, 2024, 1:34am UTC](https://community.openpbs.org/t/error-using-the-run-epilogue-shell-hook/3806 "2024-03-12T01:34:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![hiromi](https://avatars.discourse-cdn.com/v4/letter/h/bc79bd/32.png) [@hiromi](https://community.openpbs.org/u/hiromi)\
**Post date:** [March 12, 2024, 1:34am UTC](https://community.openpbs.org/t/error-using-the-run-epilogue-shell-hook/3806/1 "2024-03-12T01:34:10Z")

</div>

Hello OpenPBS community team,

I have OpenPBS 23.06 installed on Ubuntu 22.04.  
Setting up for Epilogue processing.  
I can run it properly in /var/spool/pbs/mom\_priv/epilogue script, but via Hook, I get the following error and cannot run it

```auto
03/12/2024 10:07:30;0008;pbs_mom;Job;1032.kvm-pbs;Started, pid = 9039
03/12/2024 10:07:45;0008;pbs_mom;Job;1032.kvm-pbs;Terminated
03/12/2024 10:07:45;0008;pbs_mom;Job;1032.kvm-pbs;kill_job
03/12/2024 10:07:45;0001;pbs_mom;Svr;pbs_mom;scan_for_exiting, chdir failed. ERR : Permission denied
03/12/2024 10:07:45;0006;pbs_python;Hook;pbs_python;run_epilogue_shell;1032.kvm-pbs;running epilogue.
03/12/2024 10:07:46;0001;pbs_python;Svr;pbs_python;PBS server internal error (15011) in Error evaluating Python script, <class 'AttributeError'>
03/12/2024 10:07:46;0001;pbs_python;Svr;pbs_python;PBS server internal error (15011) in Error evaluating Python script, 'AttributeError' object has no attribute 'message'
03/12/2024 10:07:46;0001;pbs_mom;Svr;pbs_mom;run_hook, execv of /opt/pbs/bin/pbs_python resulted in nonzero exit status=254
03/12/2024 10:07:46;0008;pbs_mom;Job;1032.kvm-pbs;execjob_epilogue hook 'run_epilogue_shell' encountered an exception, request rejected
03/12/2024 10:07:46;0008;pbs_mom;Job;1032.kvm-pbs;no active tasks
03/12/2024 10:07:47;0001;pbs_mom;Svr;pbs_mom;fork_to_user, chdir failed. ERR : Permission denied
03/12/2024 10:07:47;0008;pbs_mom;Job;1032.kvm-pbs;no active tasks
03/12/2024 10:07:47;0008;pbs_mom;Job;1032.kvm-pbs;kill_job

```

I have set it up in the following way

```auto
create hook run_epilogue_shell
set hook run_epilogue_shell event = execjob_epilogue
set hook run_epilogue_shell enabled = true
set hook run_epilogue_shell order = 999
set hook run_prologue_shell alarm = 35
import hook run_epilogue_shell application/x-python default run_pelog_shell.py
import hook run_epilogue_shell application/x-config default run_pelog_shell.ini``

```

Any advice would be appreciated!  
Please let me know if you need more information

Regards,  
Hiromi

---

<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:** [March 13, 2024, 7:39am UTC](https://community.openpbs.org/t/error-using-the-run-epilogue-shell-hook/3806/2 "2024-03-13T07:39:13Z")

</div>

> [@hiromi](#):
>
> ```auto
> 03/12/2024 10:07:45;0001;pbs_mom;Svr;pbs_mom;scan_for_exiting, chdir failed. ERR : Permission denied
> 03/12/2024 10:07:45;0006;pbs_python;Hook;pbs_python;run_epilogue_shell;1032.kvm-pbs;running epilogue.
> 03/12/2024 10:07:46;0001;pbs_python;Svr;pbs_python;PBS server internal error (15011) in Error evaluating Python script, <class 'AttributeError'>
> 03/12/2024 10:07:46;0001;pbs_python;Svr;pbs_python;PBS server internal error (15011) in Error evaluating Python script, 'AttributeError' object has no attribute 'message'
> 03/12/2024 10:07:46;0001;pbs_mom;Svr;pbs_mom;run_hook, execv of /opt/pbs/bin/pbs_python resulted in nonzero exit status=254
> 03/12/2024 10:07:46;0008;pbs_mom;Job;1032.kvm-pbs;execjob_epilogue hook 'run_epilogue_shell' encountered an exception, request rejected
> 
> ```

Please share the execjob\_epilogue hook.

---

<div class="post-metadata">

**Author:** ![hiromi](https://avatars.discourse-cdn.com/v4/letter/h/bc79bd/32.png) [@hiromi](https://community.openpbs.org/u/hiromi)\
**Post date:** [March 14, 2024, 12:13am UTC](https://community.openpbs.org/t/error-using-the-run-epilogue-shell-hook/3806/3 "2024-03-14T00:13:30Z")

</div>

adarsh,

Thank you for your reply.

execjob\_epilogue is:

> <https://github.com/openpbs/openpbs/blob/master/src/unsupported/run_pelog_shell.py>

I think the problem is in the following areas

```auto
    trace = {
        'line': sys.exc_info()[2].tb_lineno,
        'module': sys.exc_info()[2].tb_frame.f_code.co_name,
        'exception': sys.exc_info()[0]. __name__ ,
        'message': sys.exc_info()[1].message,
    }

```

Correct as follows:

```auto
    trace = {
        'line': sys.exc_info()[2].tb_lineno,
        'module': sys.exc_info()[2].tb_frame.f_code.co_name,
        'exception': sys.exc_info()[0]. __name__ ,
        'message': sys.exc_info()[1]
    }

```

What do you think? Is there a problem?

Hiromi,

---

<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:** [March 18, 2024, 6:33pm UTC](https://community.openpbs.org/t/error-using-the-run-epilogue-shell-hook/3806/4 "2024-03-18T18:33:50Z")

</div>

Thank you @hiromi  
Could you please share the run\_pelog\_shell.ini

---

<div class="post-metadata">

**Author:** ![hiromi](https://avatars.discourse-cdn.com/v4/letter/h/bc79bd/32.png) [@hiromi](https://community.openpbs.org/u/hiromi)\
**Post date:** [March 19, 2024, 12:05am UTC](https://community.openpbs.org/t/error-using-the-run-epilogue-shell-hook/3806/5 "2024-03-19T00:05:32Z")

</div>

adarsh,

ini file is following,

> <https://github.com/openpbs/openpbs/blob/master/src/unsupported/run_pelog_shell.ini>

No changes made to scripts or ini files

Thanks！

---

<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:** [March 20, 2024, 7:30am UTC](https://community.openpbs.org/t/error-using-the-run-epilogue-shell-hook/3806/6 "2024-03-20T07:30:11Z")

</div>

> [run\_pelog\_shell]  
> ENABLE\_PARALLEL=False  
> VERBOSE\_USER\_OUTPUT=False  
> DEFAULT\_ACTION=RERUN  
> TORQUE\_COMPAT=False

Thank you @hiromi  
Could you please try using only attribute lines without any comments and see whether it makes difference

---

<div class="post-metadata">

**Author:** ![hiromi](https://avatars.discourse-cdn.com/v4/letter/h/bc79bd/32.png) [@hiromi](https://community.openpbs.org/u/hiromi)\
**Post date:** [March 25, 2024, 3:44am UTC](https://community.openpbs.org/t/error-using-the-run-epilogue-shell-hook/3806/7 "2024-03-25T03:44:08Z")

</div>

I removed the commented lines from the hook script and ran it, but the result did not change

---

<div class="post-metadata">

**Author:** ![hiromi](https://avatars.discourse-cdn.com/v4/letter/h/bc79bd/32.png) [@hiromi](https://community.openpbs.org/u/hiromi)\
**Post date:** [April 1, 2024, 7:35am UTC](https://community.openpbs.org/t/error-using-the-run-epilogue-shell-hook/3806/8 "2024-04-01T07:35:01Z")

</div>

I changed the Line 197 of run\_pelog\_shell.py  
‘message’: sys.exc\_info()[1].message,.  
-\>‘message’: sys.exc\_info()[1].

This fix eliminates the python error, but there seems to be other problems with this Hook.

I would like to coexist with cgroup’s Hook and run the epilogue script at the end of the job. I do not intend to stick to this Hook in particular. If there is a simpler way, I would like to try it.

Any advice on how to run the epilogue script with pbs\_cgroups Hook ?

---

<div class="post-metadata">

**Author:** ![hiromi](https://avatars.discourse-cdn.com/v4/letter/h/bc79bd/32.png) [@hiromi](https://community.openpbs.org/u/hiromi)\
**Post date:** [April 3, 2024, 6:22am UTC](https://community.openpbs.org/t/error-using-the-run-epilogue-shell-hook/3806/9 "2024-04-03T06:22:19Z")

</div>

When executing an epilogue script that outputs to stdout, an error occurred with the default settings.

> 04/03/2024 14:45:55;0006;pbs\_python;Hook;pbs\_python;run\_epilogue\_shell;6.kvm-pbs;running epilogue.  
> 04/03/2024 14:45:56;0006;pbs\_python;Hook;pbs\_python;execjob\_epilogue hook run\_epilogue\_shell encountered an exception: Line 247 in stdout PermissionError: [Errno 13] Permission denied: ‘/var/spool/pbs/spool/6.kvm-pbs.OU’  
> 04/03/2024 14:45:56;0008;pbs\_mom;Job;6.kvm-pbs;Hook Error: request rejected as filter hook ‘run\_epilogue\_shell’ encountered an exception. Please inform Admin

I was able to work around this by changing the hook user to pbsuser.  
I don’t know why I can’t write to the stdout file as root, but I was able to run the epilogue for the time being!

Thank you very much.
