# Shell or Command module hangs and won't finish

**URL:** <https://forum.ansible.com/t/shell-or-command-module-hangs-and-wont-finish/18437>\
**Category:** Ansible Project\
**Created:** [June 8, 2015, 8:34pm UTC](https://forum.ansible.com/t/shell-or-command-module-hangs-and-wont-finish/18437 "2015-06-08T20:34:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emil\_Kacperski](https://avatars.discourse-cdn.com/v4/letter/e/90ced4/32.png) [@Emil\_Kacperski](https://forum.ansible.com/u/Emil_Kacperski)\
**Post date:** [June 8, 2015, 8:34pm UTC](https://forum.ansible.com/t/shell-or-command-module-hangs-and-wont-finish/18437/1 "2015-06-08T20:34:21Z")

</div>

Hello,

I am trying to run a simple bash script and it works fine on the command line. When I run it using the shell or command module it simply hangs and  
never finishes. Tried to run using the shell or command module, tried to /dev/null, sleep and using timeout. Nothing seems to work and I am  
out of ideas?

Thanks!

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 8, 2015, 8:39pm UTC](https://forum.ansible.com/t/shell-or-command-module-hangs-and-wont-finish/18437/2 "2015-06-08T20:39:00Z")

</div>

the script might not be detaching, have you tried using the script module?

---

<div class="post-metadata">

**Author:** ![Emil\_Kacperski](https://avatars.discourse-cdn.com/v4/letter/e/90ced4/32.png) [@Emil\_Kacperski](https://forum.ansible.com/u/Emil_Kacperski)\
**Post date:** [June 8, 2015, 8:48pm UTC](https://forum.ansible.com/t/shell-or-command-module-hangs-and-wont-finish/18437/3 "2015-06-08T20:48:44Z")

</div>

The script is being run on the remote machine, script don’t think will apply here.

Thanks!

---

<div class="post-metadata">

**Author:** ![Emil\_Kacperski](https://avatars.discourse-cdn.com/v4/letter/e/90ced4/32.png) [@Emil\_Kacperski](https://forum.ansible.com/u/Emil_Kacperski)\
**Post date:** [June 9, 2015, 12:01am UTC](https://forum.ansible.com/t/shell-or-command-module-hangs-and-wont-finish/18437/4 "2015-06-09T00:01:23Z")

</div>

Another problem is with bringing up a chromium-browser, wrote a little script and it works fine. But when I run it using the shell module I get the following:

Gtk: cannot open display

Made sure that export DISPLAY=:0 is in the script, also tried to run a task to export, it simply does not work. Anyone tried to bring up a chrome browser on a remote machine?

Thanks!

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 9, 2015, 12:45am UTC](https://forum.ansible.com/t/shell-or-command-module-hangs-and-wont-finish/18437/5 "2015-06-09T00:45:35Z")

</div>

in ansible use the environment: keyword for that task to set display

---

<div class="post-metadata">

**Author:** ![Emil\_Kacperski](https://avatars.discourse-cdn.com/v4/letter/e/90ced4/32.png) [@Emil\_Kacperski](https://forum.ansible.com/u/Emil_Kacperski)\
**Post date:** [June 17, 2015, 9:58pm UTC](https://forum.ansible.com/t/shell-or-command-module-hangs-and-wont-finish/18437/6 "2015-06-17T21:58:37Z")

</div>

Ok so I got everything pretty much running. Had to use environment to set the shell variable and chromium-browser has to be run in async mode. It seems  
that async mode is in seconds, is there a way to specify hours or days? Or is there a better way to run a command and not close it?

Thanks!
