DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Cron Dashboard
// log cron entries to central server
#!/bin/sh
host='localhost'
username='root'
password='root@123'
port='3306'
myhost=`hostname`
myip=`/sbin/ifconfig | grep -A2 'eth0 ' | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
for eachfile in `find /var/spool/cron/ -type f`
do
myfile=`basename $eachfile`
grep -v '^#' $eachfile | grep -v '^MAILTO' | sed '/^$/d' | while read -r myline
do
first=`echo "$myline" | awk '{print $1}'`
second=`echo "$myline" | awk '{print $2}'`
third=`echo "$myline" | awk '{print $3}'`
forth=`echo "$myline" | awk '{print $4}'`
fifth=`echo "$myline" | awk '{print $5}'`
sixth=`echo "$myline" | cut -d' ' --complement -f1-5 | sed 's/\(['"'"'\]\)/\\&/g'`
seventh=`echo "$myline" | awk -F'>|>>' '{print $2}' | sed 's/2$//'`
eighth=`echo "$myline" | awk -F'2>|2>>' '{print $2}' `
mysql -h$host -u$username -p$password -P$port -e" replace into test.mycron values ('$myhost', '$myip', '$myfile', '$first', '$second', '$third', '$forth', '$fifth', '$sixth', '$seventh', '$eighth', now())"
done
done





