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. -- .xsession_errors file grows out of control & saturates disk space https://launchpad.net/bugs/60448 -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs