How to deal with large tmp PHP files?
Sometime you may have problems with huge php<XXXXX>
files created on your server, which in some cases leads to users reaching their limits. PHP writes a large temporary file with a name like /tmp/phpQQnomb
, sometimes multiple GB in size. Usually PHP is killed before the script finishes running. It is similar to this report. When cloudLinux used, it may happen to cagefs tmp direcotry: /home/USER/.cagefs/tmp
.
For example, at /tmp/
:
stat /tmp/phph1hlVT File: ‘/tmp/phph1hlVT’ Size: 27268046848 Blocks: 53257928 IO Block: 4096 regular file Device: fd00h/64768d Inode: 68776319 Links: 1 Access: (0600/-rw-------) Uid: ( 1039/magdawasi) Gid: ( 1044/magdawasi) Access: 2019-01-29 16:37:19.810220752 +0100 Modify: 2019-01-29 16:37:19.821220752 +0100 Change: 2019-01-29 16:37:19.821220752 +0100 Birth: -
or some users with huge tmp files (between 500MB and 2GB) in /home/$USER/.cagefs/tmp/phpXXXXXX
when wordfence used with wordpress.
root@server ~]# ls -larth /home/$USER/.cagefs/tmp/php* -rw——- 1 $USER $USER 700M ago 24 10:47 /home/$USER/.cagefs/tmp/php3bLX6P -rw——- 1 $USER $USER 752M ago 24 10:48 /home/$USER/.cagefs/tmp/phpyQVlXK -rw——- 1 $USER $USER 1,2G ago 29 05:00 /home/$USER/.cagefs/tmp/phpTVL8ud -rw——- 1 $USER $USER 1,2G ago 29 19:04 /home/$USER/.cagefs/tmp/phpEWRNjt -rw——- 1 $USER $USER 1,2G ago 29 21:16 /home/$USER/.cagefs/tmp/php5IRtuJ -rw——- 1 $USER $USER 1,1G ago 30 05:47 /home/$USER/.cagefs/tmp/phppCg2ag -rw——- 1 $USER $USER 1,2G ago 30 15:31 /home/$USER/.cagefs/tmp/phpFvflBt -rw——- 1 $USER $USER 1,2G ago 30 18:55 /home/$USER/.cagefs/tmp/phpl438Jl -rw——- 1 $USER $USER 1,2G sep 1 04:40 /home/$USER/.cagefs/tmp/phpnvjn9N -rw——- 1 $USER $USER 1,2G sep 1 05:06 /home/$USER/.cagefs/tmp/php5afzuV -rw——- 1 $USER $USER 1,2G sep 1 11:52 /home/$USER/.cagefs/tmp/phpO427u7 -rw——- 1 $USER $USER 1,2G sep 1 14:39 /home/$USER/.cagefs/tmp/phpbRucIl -rw——- 1 $USER $USER 1,2G sep 3 05:57 /home/$USER/.cagefs/tmp/phpie8a2k -rw——- 1 $USER $USER 656M sep 3 16:23 /home/$USER/.cagefs/tmp/phpHNSknY -rw——- 1 $USER $USER 818M sep 3 16:24 /home/$USER/.cagefs/tmp/php5H7kSj -rw——- 1 $USER $USER 1,2G sep 3 17:41 /home/$USER/.cagefs/tmp/phpJiCASm
The customer did not upload such very large files into servers. Why did they happen?
Actually these large PHP tmp files were left behind by PHP processes, usually crashed PHP processes. It is PHP internal issue and has nothing to do with lsapi or LiteSpeed.
How to fix it? The solution for System Admin is to have an hourly cron job removing those type of temp files older than a few hours.