So I don’t know what that vendor engineer did to my EBS install, some of the concurrent manager function is spitting temporary files to my /tmp directory. The thing is, that &^%$^$** engineer insisted that he has setup that all temp files are stored in it’s EBS specific directory, and clean up process has been scheduled for them. But every couple of days my /tmp is clogged with files belonged to EBS service account
Since these files basically has no expiration date, and the scheduled clean up does not cover that particular directory, I have to set my own temp files cleaning cycle. Here is what I need :
- find files belong to the EBS service account, let’s assume it’s “oracle”
- find files within certain age range
- delete those files
- automate the task to run everyday
The last part is pretty easy with crontab. The 1-3 part must be done carefully since there is a bunch of other file on /tmp that I would rather not touch 😀
So here is the find command that I use to accomplish task 1 to 3 :
find /tmp -mtime +3 -type f -user oracle -exec rm -rf {} \;
- the -mtime +3 flag is used to search for files which were last modified 3 or more days ago
- the -type f flag is used so that the search will only find plain files only
- the -user oracle is used so that the search will only find files belong to the user “oracle”
- the -exec rm -rf {} is used so that every single files found by the search is automatically deleted. The search will find a single file at the time, and put the file name between the bracket.
At first I’m not sure whether the file should be deleted right away or not, so at first I decided that, instead of deleting the files, I move it to a temporary directory so I can review the files, and then delete them. Here is the find command that I use :
find /tmp -mtime +3 -type f -user oracle -exec mv {} /dumptmp \;
With the above command, instead of deleting the files found by the search, it move the said files to different location. I can then review and examine whether the files are save to be deleted.