Skip to content

Instantly share code, notes, and snippets.

@RoelAdriaans
Created July 29, 2018 08:49
Show Gist options
  • Save RoelAdriaans/6e5371c2fba1d61cbbd2594d767b13ab to your computer and use it in GitHub Desktop.
Save RoelAdriaans/6e5371c2fba1d61cbbd2594d767b13ab to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
lines=`journalctl -u gitlab-runner --since "30 minutes ago" | wc -l`
echo "Number of lines in jogfile: $lines"
if [ "$lines" -le 1 ]; then
uptime=`awk '{print $0/60;}' /proc/uptime`
if [ $(echo "$uptime > 20" | bc) -ne 0 ]; then
echo "We have less than one line and uptime is 20 minutes; shutting server down!"
else
echo "Uptime is less then 20 minutes, only $uptime"
fi
else
echo "More then one line; doing nothing"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment