4

I have got Cent-Os and When I have checked my /tmp directory I have found that a lot php**** files are there and they are of also big size.More interesting thing is that they are updated every-day (I got it from Last Modified date).

I found by googling "tmpwatch" can solve it but the problem is how to use it and files are modified every day and we need to give time interval in "tmpwatch" command.

So,How to stop creating such big files and if I delete them all I afraid of system crash

Below is the image of files are being created in /tmp :files are being created in /tmp

  • What is in them? Session data? – user602525 Dec 14 '13 at 06:29
  • I dont know how these files are being created. –  Dec 14 '13 at 06:32
  • I think they are php session files – user602525 Dec 14 '13 at 06:34
  • so how would i stop them? and If I delete all of them any issue will create? –  Dec 14 '13 at 06:37
  • assuming that's what they are, check out this post: http://stackoverflow.com/questions/654310/cleanup-php-session-files – user602525 Dec 14 '13 at 06:40
  • I have checked by phpinfo and from I found session.save_path=>/tmp –  Dec 14 '13 at 06:47
  • Nice, then you should be set, right? – user602525 Dec 14 '13 at 06:48
  • yes...now could you please tell me how to stop making this such big seesion or we cannot ? –  Dec 14 '13 at 06:49
  • Do you actually use sessions? – user602525 Dec 14 '13 at 06:51
  • yes,i do... it will create any site speed issue ? –  Dec 14 '13 at 06:53
  • No, just not really scalable, but if you don't have multiple servers, that doesn't matter. According to the php doc http://www.php.net/session.configuration You can set max lifetime and then it is seen as garbage. Make sure gc is turned on – user602525 Dec 14 '13 at 06:58
  • I have checked my phpinfo,I found there session.gc_maxlifetime integer => 1440 and what is mean by gc ? –  Dec 14 '13 at 07:10
  • gc = garbage collection. Those params are telling the gc what to do. You could also just write a cron job to clean out that folder periodically – user602525 Dec 14 '13 at 07:14
  • session.gc_probability => 1 session.gc_divisor => 100 –  Dec 14 '13 at 07:15
  • okay....that sound interesting of making cronjob –  Dec 14 '13 at 07:16
  • If you get sessions that big, then you must be doing something horrible in your code. Session files contain a simple serialized array, so you could manually inspect what's in them. But I'm not sure they are session files, mine are all called something like `sess_gcmj0ejtloelktqo1s48413jr0` (on centos6, php 5.3), so the name is quite different. – towr Dec 14 '13 at 10:35
  • @towr -> yes you are right.session file is started with prefix with "sess_" .The file I am getting is here two type 1st "sess_" => means session file and "php****" => dnt know ,what are they and why updating every day. –  Dec 16 '13 at 03:58
  • I think they're (partial) uploads (or at least when I do an upload php creates such files; it might possibly do so in other cases as well). You could try using the `file` command on the command-line to identify the file and see if it matches things you allow to be uploaded (say, images, or zip or pdf). It's probably uploaded files that didn't get processed properly post-upload (because of user-abort or script-failure). – towr Dec 16 '13 at 08:06
  • @towr => how to find and what to find .Is it from shell? –  Dec 16 '13 at 08:58
  • I've got the same file in my tmp folder. My php session save path is not the tmp directory so it must be something else. Any news on this? – Carl Mar 13 '14 at 06:59
  • any one find what was that ? i have the same issue – ali abdzad Sep 15 '18 at 07:44

1 Answers1

1

this files are related to io . since i am using "fopen($filePath, 'rb')" in my code , these files are creating by system and will be delete automatically (if it has enough space on /tmp folder)

if you want to change /tmp for these type of file you can change below params in your .ini file and restart apache

upload_tmp_dir='/tmp2/' sys_temp_dir='/tmp2/'

and be sure your folder has 777 + t permission , and user/group can be 'root'

ali abdzad
  • 130
  • 1
  • 10