I'm trying to manage my log file size using a cron script. I basically want to delete all but the last 2000 lines of the log file every night. I'm trying to run this command, but it seems to be emptying the entire file instead of doing what I want:
tail -2000 logfile.txt > logfile.txt
Does anyone know why this isn't working and/or how to accomplish what I want? Thanks!