Occasionally getting mails such as the following:
/etc/cron.daily/logrotate:
logrotate_script: line 2: [: /var/log/xrootd/.*.log: binary operator expected
This comes from /etc/logrotate.d/xrootd (as shipped by /etc/logrotate.d/xrootd):
/var/log/xrootd/*/*.log /var/log/xrootd/*.log
{
missingok
nomail
nocreate
rotate 100
notifempty
daily
compress
postrotate
PIPE=`dirname $1`/.`basename $1`
if [ -p $PIPE ]; then
/usr/bin/expect -c "set timeout 2; spawn /bin/sh -c \"echo ping > $PIPE\"; expect timeout { exit 1 } eof { exit 0 }" > /dev/null;
fi
endscript
}
Suspect that this error is due to the log file being absent at the time the 'postrotate' script runs. The script then gets passed the "raw" glob pattern '/var/log/xrootd/*.log', and when trying to guess the pipe name ends up with several items, which confuse the next line:
$ h='/var/log/xrootd/*.log'
$ PIPE=`dirname $h`/.`basename $h`
$ echo $PIPE
/var/log/xrootd/.*.log /var/log/xrootd/.xrootd.log
$ if [ -p $PIPE ]; then echo OK; fi
-bash: [: /var/log/xrootd/.*.log: binary operator expected
Suggest to at least quote "$PIPE" (possibly also the other variables), and/or review the logic (expect?)
—
Reply to this email directly or view it on GitHub.
Use REPLY-ALL to reply to list
To unsubscribe from the XROOTD-DEV list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=XROOTD-DEV&A=1