I'm trying to capture the ps elapsed time format for long running Siteminder process from remote server using Ansible playbook. The output of elapsed time is in the format of [[dd-]hh:]mm:ss. Need help to convert this time into seconds.
I'm trying to capture the ps elapsed time format for long running Siteminder process from remote server using Ansible playbook. The output of elapsed time is in the format of [[dd-]hh:]mm:ss. Need help to convert this time into seconds.
This is not really an ansible question but rather a linux shell question.
You can get the elapsed time in seconds using this one line shell command
$ ps -p 50 -o etime= | sed ‘s/[:-]/ /g;’ | awk ‘{print $4" " $3" " $2" " $1" " }’| awk ‘{print $1+$260+$33600+$4*86400}’
685608
Thanks a lot Tony.
I have updated the seconds conversion as below.
$ ps -p 50 -o etime= | sed ‘s/[:-]/ /g;’ | awk ‘{print $4" " $3" " $2" " $1" " }’| awk ‘{print $186400+$23600+$3*60+$4}’