It will check the file size daily and create one compressed copy whenever the file exceeds 500k, then remove the oldest copy and truncate .xsession_errors. to zero size.
I mean, why reinventing the wheel when we already have such a tool like logrotate.
Why not create a logrotate config file such as /etc/logrotate. d/xsession_ errors with the following configuration:
"/home/ */.xsession_ errors"
{
rotate 1
size 500k
copytruncate
missingok
compress
}
It will check the file size daily and create one compressed copy whenever the file exceeds 500k, then remove the oldest copy and truncate .xsession_errors. to zero size.
I mean, why reinventing the wheel when we already have such a tool like logrotate.