Right folks... this is probably something simple that I'm missing as it's early, but can anyone tell me what's going on here:
The Script:
cougar:/usr/hxscripts>vi ~/test.ksh
"/usr/home/branch/users/tech/test.ksh" [New file]
#!/bin/ksh
LOGDIR=/usr/hxscripts/LOGS/logmeoff/ # Logging directory, must be world-writable
RETDAYS=31 # Number of days to retain old logfiles
ME=`logname` # Username
SCRIPT="logmeoff" # Script name
# FUNCTIONS
###########
Log () {
set -x
##Construct the log file path and name##
LOGFILE=${LOGDIR}/${1}.`date +%a%d%b%y`.logmeoff.log
##Check whether today's logfile exists and create if not##
[ -w $LOGFILE ] || ( touch $LOGFILE; chmod 666 $LOGFILE )
##Delete logmeoff log files older than $RETDAYS old##
find $LOGDIR -type f -name '*.logmeoff.log' -mtime +$RETDAYS -exec rm {} \;
##Write the log entry##
echo "`date +%T`|`logname`|`who am i`" >> $LOGFILE
}
Log test
And the output:
cougar:/usr/hxscripts>ksh ~/test.ksh
+ + date +%a%d%b%y
LOGFILE=/usr/hxscripts/LOGS/test.Tue30Oct07.logmeoff.log
+ [ -w /usr/hxscripts/LOGS/test.Tue30Oct07.logmeoff.log ]
+ touch /usr/hxscripts/LOGS/test.Tue30Oct07.logmeoff.log
+ chmod 666 /usr/hxscripts/LOGS/test.Tue30Oct07.logmeoff.log
+ find /usr/hxscripts/LOGS -type f -name *.logmeoff.log -mtime +31 -exec rm {} ;
+ date +%T
+ logname
+ who am i
+ echo 09:06:26|tech|tech pts/1374 30 Oct 08:53 (g10wshud311.zg.if.atcsg.net)
+ 1>> /usr/hxscripts/LOGS/test.Tue30Oct07.logmeoff.log
cougar:/usr/hxscripts>ls -ld /usr/hxscripts/LOGS/logmeoff/
drwxrwxrwx 2 tech users 512 17 Oct 13:25 /usr/hxscripts/LOGS/logmeoff/
As you can see, even though I'm specifying that the LOGDIR is the existing and world-changable directory /usr/hxscripts/LOGS/logmeoff/, everything goes to /usr/hxscripts/LOGS. Why is this?!
Obviously this isn't causing me massive headaches, but I'd like to know what's going on!
Many thanks,
Alex