Categories
Tutorial

Keep last N lines of a log file with Cron

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

echo "$(tail -100 /home/greetings/public_html/sp-update/sp-status.txt)" > /home/greetings/public_html/sp-update/sp-status.txt