debugginglogrotate postrotate脚本

以下是我的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 } 

和compress-and-upload.sh脚本,

 #!/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 

文件被旋转,但是shell脚本不被执行。 我不知道如何debuggingpostscript。

是否有任何日志文件,我吱吱,看看是否有任何权限问题。

如果我直接从命令行file upload工作执行脚本。

谢谢。

logrotate通常作为一个cron作业运行,其错误最终被邮寄到root 。 看一看/var/mail/root ,或者确保/etc/aliasesroot的邮件指向某个合理的地方,并且你的实例实际上可以发送邮件。