Categories
Tutorial

Keep last N lines of a log file with Cron

If you wish to keep last (bottom) N lines of a log file and delete the older lines, you can use this command with Cron:

echo "$(tail -100 /home/home/public_html/log.txt)" > /home/home/public_html/log.txt