# Remote execution of a script never exits but times out

**URL:** <https://forum.ansible.com/t/remote-execution-of-a-script-never-exits-but-times-out/36414>\
**Category:** Ansible Project\
**Created:** [March 9, 2022, 10:00am UTC](https://forum.ansible.com/t/remote-execution-of-a-script-never-exits-but-times-out/36414 "2022-03-09T10:00:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rahul\_raviz](https://avatars.discourse-cdn.com/v4/letter/r/e9bcb4/32.png) [@rahul\_raviz](https://forum.ansible.com/u/rahul_raviz)\
**Post date:** [March 9, 2022, 10:00am UTC](https://forum.ansible.com/t/remote-execution-of-a-script-never-exits-but-times-out/36414/1 "2022-03-09T10:00:23Z")

</div>

I am writing a task in a playbook which will execute a shell script on a remote server. But for some reason it never exits and hangs and then finally times out. When I run the script directly on the remote server, there are no errors. Here is the snippet of the task.

- name: Run a script  
shell: sh /tmp/setup.sh  
become: yes

The shell script setup.sh is below. What can I do to fix this?

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [March 9, 2022, 2:32pm UTC](https://forum.ansible.com/t/remote-execution-of-a-script-never-exits-but-times-out/36414/2 "2022-03-09T14:32:02Z")

</div>

The very last line of that script is to tail the log file forever. As such, the script never finishes.

Looking at the script, I’m questioning why you wouldn’t turn it into a playbook and individual tasks instead of running that script.
