Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

logrotate does not rotate files

PS_orclNerdMar 17 2017 — edited Mar 20 2017

Hi,

I am experiencing problems with logrotate. It's interresting it does not rotate the file, only when I execute it by myself by calling logrotate -f /etc/logrotate.d/writer

My logrotate.conf is default, I haven't change there anything. What I want to achieve is to rotate files in the way that I cannot tell if the process is during logrotate writes to the file or not and I will compress only at a later time. Do you see the problem here, because I don't.

[oracle@ora01 ~]$ crontab -l

* * * * * /home/oracle/writer.sh

[root@ora01 cron.hourly]# ls -l `readlink -f writer`

-rwx------. 1 root root 68 Mar 15 15:04 /etc/cron.hourly/writer

[root@ora01 cron.hourly]# cat /etc/cron.hourly/writer

#!/bin/bash

/sbin/logrotate -f /etc/logrotate.d/writer &> /dev/null

[root@ora01 cron.hourly]# cat /var/lib/logrotate.status

logrotate state -- version 2

"/tmp/test.log" 2017-3-17-14:58:35

[root@ora01 cron.hourly]# cat /etc/logrotate.d/writer

/tmp/test.log {

    hourly

    su oracle oinstall

    missingok

    rotate 10

    notifempty

    sharedscripts

    delaycompress

    compress

    create 660 oracle oinstall

    postrotate

        /home/oracle/writer.sh logrotate

    endscript

}

[root@ora01 cron.hourly]# ls -l `readlink -f /etc/logrotate.d/writer`

-rw-r--r--. 1 root root 247 Mar 15 17:23 /etc/logrotate.d/writer

[root@ora01 cron.hourly]# cat /home/oracle/writer.sh

#!/bin/bash

if [[ -z $1 ]]; then

echo "`date +"%F %T"`: Writing inside a lot of data, you are great" >> /tmp/test.log

else

echo "`date +"%F %T"`: Writing inside a lot of data, $1" >> /tmp/test.log

fi

[root@ora01 cron.hourly]# ls -l /home/oracle/writer.sh

-rwxr-xr-x. 1 oracle oinstall 201 Mar 15 17:07 /home/oracle/writer.sh

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Apr 17 2017
Added on Mar 17 2017
4 comments
1,197 views