On 2015/5/21 15:51, Cui Bixuan wrote: > > > -------- Original Message -------- > Subject: [LTP] [PATCH] commands/logrotate:run the case once again will failed > Date: Tue, 5 May 2015 12:12:13 +0000 > From: Cui Bixuan > To: > CC: , , , Cui Bixuan > > For the first time,case do 'logrotate -fv tst_logrotate.conf' that will > create the 'half-rotated' file(messages-20150416.gz). When run case again, > the case will fail: > 'error: destination /var/log/messages-20150416.gz already exists,skipping > rotation' > > 'Logrotate' does't expect to find an already existing "half-rotated" file > (http://centos.1050465.n5.nabble.com/CentOS-Logrotate-errors-td5725868.html). > Clean the "half-rotated" file,and the case will pass all the time. > > Signed-off-by: Cui Bixuan > --- > testcases/commands/logrotate/logrotate_tests.sh | 1 + > 1 files changed, 1 insertions(+), 0 deletions(-) > > diff --git a/testcases/commands/logrotate/logrotate_tests.sh b/testcases/commands/logrotate/logrotate_tests.sh > index 2a793cc..5b14ca0 100755 > --- a/testcases/commands/logrotate/logrotate_tests.sh > +++ b/testcases/commands/logrotate/logrotate_tests.sh > @@ -191,6 +191,7 @@ test01() > do > rm -f $files > /dev/null 2>&1 > done > + rm -f /var/log/*`date '+%Y%m%d'`* > /dev/null 2>&1 If the current time is 23:59:59, a problem would occur. It is good to use the following command. rm [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] Of course, it is better if you can find a way to use regular expressions to match it. > > chmod 644 $LTPTMP/tst_logrotate.conf > logrotate -fv $LTPTMP/tst_logrotate.conf > $LTPTMP/tst_logrotate.out 2>&1 \