Job to delete out files in the /tmp directory

Previous topic - Next topic

chuckalugk

Does anyone have a job they can share that deletes out the files in a /tmp directory in USS?   I found my /tmp directory had 5900 files in it.

Justin Derrick

If you have unix-style commands available to you, and the cron scheduling tool, you can configure cron to run this command daily, which deletes files that were created x days ago:

find /tmp/ -name FILESPEC -ctime +x rm -f {} \;

PLEASE BE EXTRAORDINARILY CAUTIOUS WITH THIS COMMAND, AS IT FORCES FILES TO BE DELETED. 

Set FILESPEC to the file specification you want to use ("*.AOD") and 'x' to the number of days you want files to exist.

-JD.
Call:  +1-866-533-7742  or  eMail:  jd@justinderrick.com
IBM CMOD Wiki:  https://CMOD.wiki/
FREE IBM CMOD Webinars:  https://CMOD.Training/
IBM CMOD Professional Services: https://CMOD.cloud

Interests: #AIX #Linux #Multiplatforms #DB2 #TSM #SP #Performance #Security #Audits #Customizing #Availability #HA #DR

rjchavez

We have a CRON job/command that performs clanup automatically for any file older than 7-days (-mtime +7). 

0 0 * * * find /tmp/ -type f -mtime +7 -exec rm -v {} \; > /tmp/tmp_rm.txt &