Categories
Tutorial

Keep first N lines of a log file with Cron

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

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