uacomm

Member
Apr 15, 2011
22
0
51
My /tmp directory get 100% full in every 3 to 4 days which cause most of services un-accessible until I clean up the /tmp manually.

How can I set a cron to auto lean /tmp daily/
 

LinuxTechie

Well-Known Member
Jan 22, 2011
502
9
68
cPanel Access Level
Root Administrator
Hello,

I thinks you need to use tmpwatch.

Definition: tmpwatch: The tmpwatch utility recursively searches through specified directories and removes files which have not been accessed in a specified period of time. Tmpwatch is normally used to clean up directories which are used for temporarily holding files (for example, /tmp). Tmpwatch ignores symlinks, won't switch filesystems and only removes empty directories and regular files.

Please use the URL for cron details : /http://prefetch.net/blog/index.php/2009/05/01/automating-temporary-file-cleanup-with-tmpwatch/
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
38
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
Please ensure not to set the cron times or tmpwatch to clear /tmp in less then a 6 to 12 hour period. If you have it clearing files that are younger than 6-12 hours (I've seen some users set it at 5 minutes), you will break some components such as EasyApache from working when it compiles. This is because EasyApache will write some temporary files to /tmp and take longer than 5 minutes to run.
 

uacomm

Member
Apr 15, 2011
22
0
51
Hello,

I thinks you need to use tmpwatch.

Definition: tmpwatch: The tmpwatch utility recursively searches through specified directories and removes files which have not been accessed in a specified period of time. Tmpwatch is normally used to clean up directories which are used for temporarily holding files (for example, /tmp). Tmpwatch ignores symlinks, won't switch filesystems and only removes empty directories and regular files.

Please use the URL for cron details : /http://prefetch.net/blog/index.php/2009/05/01/automating-temporary-file-cleanup-with-tmpwatch/
I have readout the above url for tmwatch but cannot understand how to set out it to clean in every 12 hours. So can you please give me step by step instructions that how can I set tmpwatch to clear it in every 12 hours.
 

uacomm

Member
Apr 15, 2011
22
0
51
I have set that cron but still /tmp get full some times. So how can I determine what actually is the problem? Why tmp is getting full?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,203
363
I have set that cron but still /tmp get full some times. So how can I determine what actually is the problem? Why tmp is getting full?
You can browse to the /tmp directory via the command line, and use the following commands to determine which files are using the most disk space:

Code:
# cd /tmp
# du -sh * .[a-zA-Z]*
Thank you.
 

uacomm

Member
Apr 15, 2011
22
0
51
I run that command and I looked /tmp folder via winscp root login. There are lot of files like:

4.0K sess_fbec1bb87c9d1df25813f2fa8a0565cf
0 sess_fbee02d8231866477dd6089ac8239f06


But I think above types files are not problematic. I also see lot below types files:

37M #sql_3287_0.MYD
4.0K #sql_3287_0.MYI
21M #sql_3287_1.MYD
4.0K #sql_3287_1.MYI

I don't know what types of these #sql_3287_0.MYD? These sql files are filling the /tmp so how can I prevent these files to filling the /tmp
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
38
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
Those files are for MySQL for temporary MyISAM tables. To prevent MySQL from using /tmp for those temporary tables, you can change the tmpdir location for MySQL in /etc/my.cnf file. In the [mysqld] section of /etc/my.cnf, put the following:

Code:
tmpdir=/mysqltmp
At that point, then create that directory:

Code:
mkdir /mysqltmp
chown -R mysql:mysql /mysqltmp
Then restart MySQL:

Code:
/etc/init.d/mysql restart
At that point, any future temporary tables should end up writing to /mysqltmp instead. You can check it did change to that location by running the following command to check it:

Code:
mysqladmin var | grep tmpdir