[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

spooky script



Hi all,
i made the following script and added it to crontab:
@monthly                                /home/jabal/Scripts/wwwpro.scr &&
mail -s "Maandelijks weblog verplaatst" jabal

no mail was send.
the spooky thing is that although the script was made to archive my
logfiles, my apache webserver decided to log new events in the file i moved
the log to. httpd.conf has not been edited.

Does anyone have an explanation for this? is it maybe that mv is not
simmilar to cp - rm. should i try cp?

#!/bin/sh
#
# Script for managing APACHE access and error logs
# both logs will be kept in the same hierarchy:
# ~YEAR/year-month-day.a
# ~YEAR/year-month-day.e
# Intended to be invoked by Cron monthly. More often is no problem.
# You might want to consider adding an extra hierarchy level.
#
# ----------EXECUTE AS ROOT!----------
#
# copyright (c) 2004 by Mercator Trading
# special thanks to Jochem Kossen (jk.yazzy.org) for providing syntax

#---------------------------------------------------------------------------
---
# Configure these settings:
#---------------------------------------------------------------------------
---

# Which path to move the log files to?
DEST_PATH="/var/www/logs/Profibas"

# Where can I find the current access log?
CURRENT_ACCESS_LOG="/var/www/logs/profibas_access_log"

# Where can I find the current error log?
CURRENT_ERROR_LOG="/var/www/logs/profibas_error_log"

#---------------------------------------------------------------------------
---
# Definitions:
#---------------------------------------------------------------------------
---

DATE=`date +%Y-%m-%d` # 2004-02
YEAR=`date +%Y` # 2004

#---------------------------------------------------------------------------
---
# Code at Work:
#---------------------------------------------------------------------------
---

# test if DEST_PATH exists
if [ ! -e "$DEST_PATH" ]; then
mkdir "$DEST_PATH"
chmod 0744 "$DEST_PATH"
fi

# test if YEAR exists
if [ ! -e "$DEST_PATH/$YEAR" ]; then
mkdir "$DEST_PATH/$YEAR"
chmod 0744 "$DEST_PATH/$YEAR"
fi

# the actual 'stoelen dans'
mv "$CURRENT_ACCESS_LOG" "$DEST_PATH/$YEAR/$DATE.a"
mv "$CURRENT_ERROR_LOG" "$DEST_PATH/$YEAR/$DATE.e"

#---------------------------------------------------------------------------
---
# APACHE will re-touch the log files... I hope ;) nope...
#------------------------------------END------------------------------------
---

touch "$CURRENT_ACCESS_LOG"
touch "$CURRENT_ERROR_LOG"
chmod 0644 "$CURRENT_ACCESS_LOG"
chmod 0644 "$CURRENT_ERROR_LOG"