Search code examples
linuxcronredhatdelete-file

Cronjob not ending when deleting files


When my cronjob runs it doesn't appear to end. Its a simple job to delete some files every 2 days. The job wont end and it deletes the file but will not release the space without a reboot. Now the machine has no free storage unless it is rebooted. Has anyone else experienced this and if so how did you fix/resolve it?

0 23 */2 * * /usr/bin/find "var/log/" -name "messages*" -delete

Here is my cronjob


Solution

  • That means that the files are used by some other process. In Unix, when you delete the file, the inode and the space are not reclaimed as long as some process has still a file descriptor open on it.

    You can easily find which are the process holding it using lsof /var/log