I've a system that writes files to
/var/tmp/log/my.log, I want to write a shell script to rotate the log files when it reaches 1KB limit, so my my.log becomes my.log.1, my.log.1 becomes my.log.2 and so on until my.log.10 and then the other files are deleted.
I got some part of the script but don't know how to change the file names.
file_size=`du -b /var/tmp/log/my.log`
if($file_size -gt 1024)
mv my.log my.log.1
I need to move my.log to my.log.1 when my.log reaches 1KB limit and then move my.log.1 to my.log.2 so that the my.log can move to my.log.1 after it reaches 1KB second time and so on. Is there any way to do this without using logrotate ?