Skip to content

Instantly share code, notes, and snippets.

@arbovm
Created November 20, 2012 13:04
Show Gist options
  • Save arbovm/4117846 to your computer and use it in GitHub Desktop.
Save arbovm/4117846 to your computer and use it in GitHub Desktop.
query next chef run on a given server
#!/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