Debugging logrotate postrotate script
Posted
by
robert
on Server Fault
See other posts from Server Fault
or by robert
Published on 2013-06-25T08:26:38Z
Indexed on
2013/06/25
10:23 UTC
Read the original article
Hit count: 277
Following is my logrotate conf.
/mnt/je/logs/apache/jesites/web/*.log" {
missingok
rotate 0
size 5M
copytruncate
notifempty
sharedscripts
postrotate
/home/bitnami/.conf/compress-and-upload.sh /mnt/je/logs/apache/jesites/web/ web
endscript
}
And compress-and-upload.sh script,
#!/bin/sh
# Perform Rotated Log File Compression
tar -czPf $1/log.gz $1/*.1
# Fetch the instance id from the instance
EC2_INSTANCE_ID="`wget -q -O - http://169.254.169.254/latest/meta-data/instance-id`"
if [ -z $EC2_INSTANCE_ID ]; then
echo "Error: Couldn't fetch Instance ID .. Exiting .."
exit;
else
/usr/local/bin/s3cmd put $1/log.gz s3://xxxx/logs/$(date +%Y)/$(date +%m)/$(date +%d)/$2/$EC2_INSTANCE_ID-$(date +%H:%M:%S)-$2.gz
fi
# Removing Rotated Compressed Log File
rm -f $1/log.gz
The files are rotated, but shell script is not executed. I don't know how to debug the postscript.
Is there any logfile I chek to see if there is any permission issues.
If i directly execute the script from commandline file upload works.
Thanks.
© Server Fault or respective owner