OnDemand User Group

Support Forums => z/OS Server => Topic started by: chuckalugk on December 04, 2020, 09:49:29 AM

Title: Job to delete out files in the /tmp directory
Post by: chuckalugk on December 04, 2020, 09:49:29 AM
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.
Title: Re: Job to delete out files in the /tmp directory
Post by: Justin Derrick on December 06, 2020, 02:27:24 PM
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.
Title: Re: Job to delete out files in the /tmp directory
Post by: rjchavez on December 18, 2020, 09:13:04 AM
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 &