Author:
erics , August 1st, 2019
Every time I use awk, my respect for it grows! Like grep, find and rsync, it is one of the powerhouse command-line tools in my arsenal. Recently, I needed to list all MySQL binary log files from a starting file forwards in sequence. AWK to the rescue! For example, I knew the starting file was […]
Categories: How-To's , Technology Tags: AWK , binary log file , howto , Index , Log , log file , Match , mysql , tips
| No comments
Author:
erics , September 15th, 2015
The script to check and restart apache…works on CentOS – YMMV!
#!/bin/bash
MAXLOAD = 6
check = $ ( uptime | awk - F 'average: ' '{print $2}' | awk '{print $1}' | tr - d ',' )
if [ [ $check > $MAXLOAD ] ] ; then
/ sbin / service httpd stop
HOST = ` hostname `
echo $HOST | mailx - s "$HOST load alert - apache STOPPED by cron script" load .alert @ your .domain
sleep 300
/ sbin / service httpd start
echo $HOST | mailx - s "$HOST load alert - apache STARTED by cron script" load .alert @ your .domain
fi
Add to cron * * * * * /root/restart_apache_if_load_hits_threshold.sh >> /var/log/restart_apache_if_load_hits_threshold.log 2>&1
Categories: How-To's , Technology Tags: apache , AWK , bash , CentOS , howto , httpd , Load , load average , Restart , Stop , tips , Uptime
| No comments
Author:
erics , January 1st, 2015
awk ‘{sum+=$1}END{print sum}’ inputFile
Categories: How-To's , Technology Tags: Add , AWK , bash , Command line , howto , Math , Shell , Sum , tips
| No comments