How to set timeout value for a task using shell module?

18 views
Skip to first unread message

Saravanan

unread,
Dec 28, 2018, 11:53:51 AM12/28/18
to Ansible Project
Hi Ansible Experts,
We are running tasks using shell module. Sometime these tasks are pending due to backend application server slow response. Is there anyway to set timeout for these tasks to exit after certain time period?

Regards
Saravanan

Piyush Bansal

unread,
Dec 28, 2018, 11:55:01 AM12/28/18
to ansible...@googlegroups.com
Have u explored async mode ??

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/53713c72-2f3d-4865-b105-6c25844e07b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

S C Rigler

unread,
Dec 28, 2018, 1:17:15 PM12/28/18
to ansible...@googlegroups.com
Assuming the target machine is running a modern Linux version, you can
run the "timeout" command in your shell.

Like:

- shell: timeout -s 9 10 /usr/bin/command that does something

That will send a "kill -9" to the command if it doesn't finish in 10 seconds.

Saravanan

unread,
Dec 29, 2018, 3:35:56 PM12/29/18
to Ansible Project
Thank you Steve.
Reply all
Reply to author
Forward
0 new messages