Running ansible tasks in background and disown

181 views
Skip to first unread message

Kaustav Majumder

unread,
May 15, 2019, 2:23:42 AM5/15/19
to Ansible Project
Hi all, i am trying to top , sar , iostats in the backgound via ansible on remote hosts and collect stats redirecting outpu to a log file while I run other tasks from my local machine. I have tried - name: collect hypervisor stats hosts: all tasks: - name: execute sar iostat scripts shell: top -bd $MON_INTERVAL > $GLUSTER_PROFILER_RESULTS/top_proc.$HOSTNAME.txt & disown but it stops by itself. I want to kill the tasks after sometime manually. Is there any way

Jonathan Lozada De La Matta

unread,
May 15, 2019, 6:46:19 AM5/15/19
to ansible...@googlegroups.com
ansible facts can't get the information? 

On Wed, May 15, 2019 at 2:23 AM Kaustav Majumder <kmaj...@redhat.com> wrote:
Hi all, i am trying to top , sar , iostats in the backgound via ansible on remote hosts and collect stats redirecting outpu to a log file while I run other tasks from my local machine. I have tried - name: collect hypervisor stats hosts: all tasks: - name: execute sar iostat scripts shell: top -bd $MON_INTERVAL > $GLUSTER_PROFILER_RESULTS/top_proc.$HOSTNAME.txt & disown but it stops by itself. I want to kill the tasks after sometime manually. Is there any way

--
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/dc2fc2b7-1c81-4f95-812e-eaba57665445%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Jonathan Cha'gara Lozada De La Matta

He / Him / His

Automation Practice

Senior Automation Consultant & Automation CoP Manager

Red Hat


 

Adam E

unread,
May 15, 2019, 7:14:38 PM5/15/19
to Ansible Project

not sure if you would get different results, but maybe try nohup instead of disown.  ie.
- name: execute sar iostat scripts shell: nohup top -bd $MON_INTERVAL > $GLUSTER_PROFILER_RESULTS/top_proc.$HOSTNAME.txt &

Another option could be to use the "at" module to schedule a task to start immediately. ie..
- name: Schedule a command to execute in 0 minutes as root.
  at
:
    command
: top -bd $MON_INTERVAL > $GLUSTER_PROFILER_RESULTS/top_proc.$HOSTNAME.txt
    count
: 0
    units
: minutes

Reply all
Reply to author
Forward
0 new messages