Ich habe das folgende Skript (trapsize), dass die Kontrollen eine Dateigröße auf meinem Syslog-Server, und wenn die Datei GT 6g, wird Mail-Benachrichtigung an den Admin für die Inspektion. Die folgenden Arbeiten wie ein Champ, wenn ich ausführen. / Trapsize angemeldet als Benutzer "root" mit Bash-Shell.
Code:
FILESIZE=$(ls -l /opt2/fwsm/fwsm | tr -s " " "\t" | cut -f5)
MAILGROUP="userA@conus.army.mil, userB@conus.army.mil, userC@conus.army.mil"
if [ $FILESIZE -lt 6000000000 ]
then
: # no action required
else
echo "$FILESIZE" | mailx -r userD@post.army.mil -s "File Size Limit of 6g Reached on fwsm" $MAILGROUP
fi
Ich muss das Skript in / usr / lib mit root: bin Eigentümer und Berechtigungen so eingestellt, dass Cron können Sie das Skript zu verschiedenen Zeiten während des Tages.
Ich habe das Folgende in / usr / lib / trapsize für cron, aber ich kann es nicht funktionieren. Jede Beratung wird gebeten.
Code:
#! /bin/sh
#
# Script will periodically check the log size for the FWSM and notify admin if greater than 6g - jbrannen
#
#
#
FILE=fwsm
FILEPATH=/opt2/fwsm/
FILESIZE=$(ls -l $FILEPATH$FILE | tr -s " " "\t" | cut -f5)
MAILGROUP="userA@conus.army.mil, userB@conus.army.mil, userC@conus.army.mil"
if [ $FILESIZE -lt 6000000000 ]
then
: # no action required
else
echo "$FILESIZE" | mailx -r userD@post.army.mil -s " File Size Limit of 6g reached on fwsm" $MAILGROUP
rm $FILESIZE
fi
Der Fehler wird wie folgt;
trapsize: Syntaxfehler in Zeile 10: "FileSize \u003d $ 'unerwartete