# Running a shell command when exiting an Elixir script

**URL:** <https://forum.elixirforum.com/t/running-a-shell-command-when-exiting-an-elixir-script/71785>\
**Category:** Questions\
**Tags:** script, mix-tasks\
**Created:** [July 22, 2025, 6:46pm UTC](https://forum.elixirforum.com/t/running-a-shell-command-when-exiting-an-elixir-script/71785 "2025-07-22T18:46:30Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![Hermanverschooten](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/hermanverschooten/32/6447_2.png) [@Hermanverschooten](https://forum.elixirforum.com/u/Hermanverschooten)\
**Post date:** [July 23, 2025, 6:43pm UTC](https://forum.elixirforum.com/t/running-a-shell-command-when-exiting-an-elixir-script/71785/8 "2025-07-23T18:43:59Z")

</div>

I don’t remember the code it is too long ago I wrote it.  
But what comes to mind is if you could pass along the current file descriptors for input and output to the new process or could be you need to start a pty.

---

_[View the full topic](https://forum.elixirforum.com/t/running-a-shell-command-when-exiting-an-elixir-script/71785)._
