Should I rotate cpgreylistd.log ?

cPanelAaronH

Well-Known Member
Staff member
Dec 31, 2014
70
19
133
Houston Texas
cPanel Access Level
Root Administrator
Hey there,

If your log is growing in size, it is a good idea to rotate or compress the log.

This should work for you if you want to create a new configuration and rotate the log:


Create the file:

Code:
vi /etc/logrotate.d/greylisting
Copy the code:

Code:
/usr/local/cpanel/logs/cpgreylistd.log {
    rotate 3
    compress
    missingok
    notifempty
    sharedscripts
    postrotate
        /scripts/restartsrv_cpgreylistd
    endscript
}
Verify your configuration which will run the new greylisting log rotate file we created.


Code:
/usr/sbin/logrotate -f /etc/logrotate.conf
Before:

Code:
[[email protected] public_html]# stat /usr/local/cpanel/logs/cpgreylistd.log
  File: ‘/usr/local/cpanel/logs/cpgreylistd.log’
  Size: 1359470       Blocks: 2664       IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 1806457     Links: 1
Access: (0600/-rw-------)  Uid: (    0/    root)   Gid: (    0/    root)
Context: system_u:object_r:usr_t:s0
Access: 2020-10-28 19:41:07.053725090 -0500
Modify: 2020-10-29 19:54:46.311754460 -0500
Change: 2020-10-29 19:54:46.311754460 -0500
Birth: -
After:

Code:
[[email protected] public_html]#  stat /usr/local/cpanel/logs/cpgreylistd.log
  File: ‘/usr/local/cpanel/logs/cpgreylistd.log’
  Size: 189           Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 711791      Links: 1
Access: (0600/-rw-------)  Uid: (    0/    root)   Gid: (    0/    root)
Context: system_u:object_r:usr_t:s0
Access: 2020-10-29 20:00:00.322765690 -0500
Modify: 2020-10-29 20:00:15.470766232 -0500
Change: 2020-10-29 20:00:15.470766232 -0500
Birth: -
And then we can confirm the file was rotated and compressed.

Code:
[[email protected] public_html]# ls -lah /usr/local/cpanel/logs/cpgreylistd*
-rw-------. 1 root root 189 Oct 29 20:00 /usr/local/cpanel/logs/cpgreylistd.log
-rw-------. 1 root root 45K Oct 29 19:55 /usr/local/cpanel/logs/cpgreylistd.log-20201029.gz

I hope this helps.