[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Deleting Temp files using tmpwatch

Posted on 2010-03-31
9
Medium Priority
?
2,087 Views
Last Modified: 2013-12-06
I have a CPanel server that using PHP 5.x and run's eaccelerator. The temp files from eaccelerator are filling up my temp disk too quickly and I'd like to run a cron job using tmpwatch to delete the files but the command I'm using to test the delete I'm not getting to work correctly. Can someone help me w/ this?
Here's my command:
tmpwatch -f  24 /usr/tmp/eaccelerator/1/1
It runs w/ no error but does not delete the files over 24hrs. old.

JohnP
0
Comment
Question by:pcshost
  • 5
  • 3
9 Comments
 
LVL 13

Expert Comment

by:Superdave
ID: 29294954
What is in the tmpwatch script?
0
 
LVL 7

Expert Comment

by:ajay_mhasal
ID: 29305321
Hi,

I think the problem is of permissions and you need to run this command either from the owner of those files or from root. Following command should work fine to delete the files which are not accessed from last 24 hrs. Also if you wish to check why your current command is not deleting the files then use "--verbose" option with your command i.e.

tmpwatch --verbose  24  /usr/tmp/eaccelerator/1/1


I hope this will work!
0
 

Author Comment

by:pcshost
ID: 29338964
I don't have a tmpwatch script. I'm just running the command from the command prompt as root and no, oddly enough it doesn't work. I can run rm *.* and delete the files fine and just skip the current one's but the tmpwatch doesn't work plus it doesn't with the verbose switch on, list anything it does.

I'm also thinking that I did delete the files from the eaccelerator/1/1 folder yesterday but I'm seeing there were new one's today with old dates so I have to verify that I'm not hallucinating and see if that has something to do with it. I'll also test this command on another part of the server.  Thx.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 

Author Comment

by:pcshost
ID: 29339846
addendum:
tmpwatch --verbose  24  /usr/tmp/eaccelerator/1/1  Didn't work BUT
tmpwatch --verbose  0  /usr/tmp/eaccelerator/1/1 did remove the files so the argument 24 is the issue. The default is u: --atime but is there some other argument's I need to use to delete files after 24 hours?

0
 
LVL 7

Expert Comment

by:ajay_mhasal
ID: 29339954
Hi,

By default tmpwatch deletes files which are not accessed in last 24 hrs. i.e. by referring the atime of the file (Note that the periodic updatedb file system scans keep the atime of directories recent.) You can check the access,modify and creation time of file using stat command eg.

stat <file name>
0
 

Author Comment

by:pcshost
ID: 29341310
So all I need to do is technically run the tmpwatch command at the eaccelerator root and it'll delete anything over 24 hours?
0
 
LVL 7

Expert Comment

by:ajay_mhasal
ID: 29344395
HI,

Yes but only if the files are not accessed within last 24 hrs. and somehow the files are accessed within 24 hrs (By programs like updatedb) and if you still wish delete those then try following command.

tmpwatch -ctime 24 /usr/tmp/eaccelerator/1/1

In your case when the file are getting deleted by using 0 instead of 24 means some program on your system has accessing those files within 24 hrs.

Also note that if you use 24 as a time parameter then tmpwatch will calculate 24 hrs. from the time when you actually runs the command tmpwatch and not the last day.
0
 

Author Comment

by:pcshost
ID: 29366435
Oh that last part makes sense. So I'll run the tmpwatch command and then 24 hours from now I should see the files disappear? I'll do that.

Thx
0
 

Accepted Solution

by:
pcshost earned 0 total points
ID: 29568471
The tmpwatch wasn't working. I did find this command which did delete files that we're over 24hrs not accessed in the tmp/eaccelerator directory:

find /tmp/eaccelerator ! -mtime -1 -type f -exec rm {} \;

John
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Virtualization software lets you run different versions of Windows, Ubuntu Linux and other versions of Linux all at the same time, rather than running each one directly from your computer's hard drive.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to moveā€¦
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

608 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question