Operating System - HP-UX
1826103 Members
4398 Online
109690 Solutions
New Discussion

Re: Can't Remove files in a tmp directory with MANY files

 
SOLVED
Go to solution
John Froese_1
Occasional Advisor

Can't Remove files in a tmp directory with MANY files

Getting error below when attemp to remove(rm .../tmp/* )files in a tmp dir.

sh: /usr/bin/rm: arg list too long

When I rm -rf the directory, there are so many files that the rm command just runs forever - (hours ) without getting ahead of the additions to the tmp dir.

Any ideas on how to quickly remove a directory that has many(i don't know how many) files?

thanks - John
5 REPLIES 5
Pete Randall
Outstanding Contributor
Solution

Re: Can't Remove files in a tmp directory with MANY files

John,

Try the find command:

Find /tmp/ -name filename* |xargs rm


Pete

Pete
Jeff Schussele
Honored Contributor

Re: Can't Remove files in a tmp directory with MANY files

Hi John,

Pete's answer will do the trick for you now, but, you need to determine just what's loading up the /tmp directory. It should *solely* be the domain of the OS - NOT - application SW nor users. They should be using /var/tmp.
If you don't already have the lsof utility, get it, install it & use it to determine just what process(es) are placing those files. It could also turn out to be a runaway normal OS function, but the bottom line is that this is indicative of a problem or misconfiguration.

My $0.02,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Sanjay_6
Honored Contributor

Re: Can't Remove files in a tmp directory with MANY files

Hi John,

Is this system 10.20

Check out this link below,

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=765004

Hope this helps.

Regds
John Froese_1
Occasional Advisor

Re: Can't Remove files in a tmp directory with MANY files

Thanks Pete and Jeff,
Yes the solution from Pete is working - ie I am gaining freespace faster than I am losing it. And yes - Jeff, I am looking into the cause of the inserts to this tmp dir - it (tmp)is an application dir, and seems to be running away with itself. I know what should be writing to the dir - but cannot yet explain why I am getting so many fles written to it yet. I run a cron to delete files daily, but obviously something else ia at play here.

Thanks!
John Froese_1
Occasional Advisor

Re: Can't Remove files in a tmp directory with MANY files

Thanks again!- have resolved both the issue of removing files (when there are so many of them) and the application issue that was constantly writing to tmp dir.
John