Created
November 20, 2012 13:04
-
-
Save arbovm/4117846 to your computer and use it in GitHub Desktop.
query next chef run on a given server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ssh $1 <<EOF | |
ps_line=\$(ps aux | grep chef-client | grep sleep ) | |
secs=\$(echo \$ps_line | grep -o 'sleep [0-9]*' | cut -d' ' -f2) | |
start=\$(echo \$ps_line | awk '{print \$9}') | |
start_min=\$(echo \$start | cut -d':' -f 1) | |
start_sec=\$(echo \$start | cut -d':' -f 2) | |
next_run_in_day_mins=\$(expr \$start_min \\* 60 + \$start_sec + \$secs / 60) | |
echo "its \$(date +%H:%M) chef-client started at \$start, re-runs at \$(expr \$next_run_in_day_mins / 60):\$(expr \$next_run_in_day_mins \% 60)" | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment