#!/bin/bash
mkdir /var/log/cyfs_log_bak
mkdir /var/log/cbs_log_bak
touch /etc/logrotate.d/cbs_log
touch /etc/logrotate.d/cyfs_log
touch /usr/local/log_bak.sh

echo '/cyfs/log/*/*.log 
/cyfs/log/app/*/*.log
/cyfs/log/app/*/*/*.log {
        su root root
        hourly
        size 3M
        notifempty
        compress
        copytruncate
        olddir  /var/log/cyfs_log_bak/
        dateext
        dateformat -%Y%m%d%H.%s
        missingok
        rotate 48
        create 0644 root root
}
' > /etc/logrotate.d/cyfs_log

echo '/cyfs/vood/cbs/cbs.log {
        su root root
        hourly
        size 10M
        notifempty
        compress
        copytruncate
        olddir /var/log/cbs_log_bak/
        dateext
        dateformat -%Y%m%d%H.%s
        missingok
        rotate 48
        create 0644 root root
}
' > /etc/logrotate.d/cbs_log

echo '#!/bin/bash
find /var/log/cbs_log_bak/ -mtime +1 -type f -exec rm -rf {} \;
find /var/log/cyfs_log_bak/ -mtime +1 -type f -exec rm -rf {} \;
' > /usr/local/log_bak.sh

chmod +x /usr/local/log_bak.sh

echo '0 2 * * * root /usr/local/log_bak.sh
*/60 * * * * root /usr/sbin/logrotate -vf /etc/logrotate.d/cbs_log
*/60 * * * * root /usr/sbin/logrotate -vf /etc/logrotate.d/cyfs_log
' > /etc/crontab
