On Wed, 20 May 2020 00:29:19 -0700 (PDT)
Jenisha T <[email protected]> wrote:

> I need to kill a process if its older than 1 hour.  I have process id how 
> to check if its older than 1 hour

There is no such Ansible module. It'll be necessary to use 'command'. For
example, in Linux or *BSD, get elapsed time of the process in seconds

    - command: 'ps -o etimes -p {{ my_pid }}'
      register: result
    - debug:
        var: result.stdout_lines

and kill the process if it's older than 1 hour

    - command: 'kill {{ my_pid }}'
      when: result.stdout_lines.1|int > 3600

HTH,

        -vlado

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200520102612.55dee4ca%40gmail.com.

Attachment: pgpKn_CIk1Jzm.pgp
Description: OpenPGP digital signature

Reply via email to