I have a playbook which runs on multiple servers to monitor the hung cron
processes count. If the host has hung processes, the playbook will kill the
processes and it will restart the crond service.
My requirement is to generate the file report that should contain the
hostname where it hung crond processes and the count. Please assist me with
this.
- name: Getting process IDs of Cron
shell: ps -ef | grep crond| egrep -v "incrond|grep" | wc -l
register: pids_of_cron
- name: Restart service cron if its hung
shell: ps -ef | grep crond| egrep -v "incrond|grep"| awk '{print
$2}'| xargs -i kill -9 {}
when: pids_of_cron.stdout | int > 1
- name: Getting process IDs of Cron
shell: ps -ef | grep crond| egrep -v "incrond|grep" | wc -l
register: pids_of_cron
- name: start service cron if not running
service:
name: crond
state: started
when: pids_of_cron.stdout | int == 0
--
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/f881ac92-a3d8-40f1-b05e-9561f028b7fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.