
Originally Posted by
jols
Spiral, sounds like just what the doctor ordered.
Care to post the script that's run by your cron? Last time I tried to set up a shell script to do something like this it caused CPU overloads. I'm really not very good at this kind of thing.
The following is not what we use ...
However, someone in another thread asked almost an identical question about error_logs literally
just a couple of minutes ago and I wrote them a quick script to locate and archive the error_log files so
here is a variation of the script I just posted in the other thread just a minute ago except rewritten
to be more used as a cronjob and may be useful to what you are doing as well and should be easily
modified to add whatever additional functionality you need:
Code:
#!/bin/bash
IFS="$"
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/usr/mbin:.
export PATH
unset USERNAME
TLOG="/tmp/tmp_error_search.$$"
ELOG="/var/log/client_error_logs.log
# Reset temporary work file if exists
if [ -e ${TLOG} ]; then
rm -f ${TLOG}
/bin/touch ${TLOG}
/bin/chmod 600 ${TLOG}
fi
cd /home #Nice starting point
ls /var/cpanel/users | while read CPLN; do
echo "$(date) I will now search ${CPLN}'s account for PHP error_log files ..." >> ${ELOG}
find /home/${CPLN}/public_html -type f -name 'error_log' > ${TLOG}
done
if [ -e ${TLOG} ]; then
echo "$(date) I have built my list of error_log files and am now archiving those files ..." >> ${ELOG}
cat ${TLOG} | while read MLINE; do
if [ -e ${MLINE}.bz2 ]; then
rm -f ${MLINE}.bz2
echo "$(date) Removed old archive ${MLINE}.bz2 from hard drive ..." >> ${ELOG}
fi
echo "$(date) Compressing ${MLINE} into new bzip2 archive ..." >> ${ELOG}
bzip2 -9 "${MLINE}" > /dev/null 2>&1
done
rm -f ${TLOG}
fi