Project

General

Profile

Bug #67366 ยป monitor_error_log.sh

Tobias Schaefer, 2015-08-06 16:27

 
#!/bin/bash

logfile=/var/log/apache2/error_log
searchstr='PHP Fatal error: Class'
cachefile='/var/log/apache2/lastpos_PHP_Fatal_error'
typo3path='/srv/www/htdocs/cms/'

[ -f $cachefile ] && lastpos=$(<$cachefile)
[ "$lastpos" ] || lastpos=0

newpos=$(stat -c %s $logfile)

[ $lastpos -gt $newpos ] && lastpos=0

errorfound=$(tail -c +$lastpos $logfile | grep "$searchstr")

echo $newpos >$cachefile
echo $errorfound
[ "$errorfound" ] && ( rm -R $typo3path'typo3temp/Cache/Code' $typo3path'typo3temp/Cache/Data' )
    (1-1/1)