I created a log file by running the iostat
command to a text file, and ran the command in the background using nohup
.
#nohup iostat -xm 5 > /z/logfile.txt &
Later on, I created a cronjob that runs every ten minutes doing the same as above, after I realized my process was being killed by a reboot. I've also setup log-rotation as below:
/z/logfile.txt {
size 20M
rotate 0
create 0644 root root
missingok
notifempty
}
Now I have realized that the logfile.txt
gets deleted but the iostat
command keeps pointing at deleted files as shown by the lsof -n | grep deleted
command. There the disk space is not freed.
How can I make sure the files are rotated and thereafter iostat
points to the newly created file, freeing up disk space?
Any ideas how to set it up correctly?