I don't usually do this kind of stuff, so I just have to ask. How do I make a script which checks a log file, lets say it's named log.txt, grabs everything but the first 100 000 lines from it to a new log.txt file and deletes the old log.txt? It would also have to run monthly.
So far with my zero coding knowledge I've only managed to make a script which would delete the log.txt once a month (new one generates automatically), but I would really like to keep data except the oldest 100 000 entries as mentioned below.
Here's the old script
#!/bin/sh
find /mnt/usb_storage/ -type f -name "log.txt" -exec rm -r {} \;
how I implemented it:
# cd /privRoot
# chmod 755 deleteLogMonthly.sh
# crontab -e
59 23 1 * * deleteLogMonthly.sh