On the server with Ubuntu hosted site. Once every two weeks stably falls with an error

SQLSTATE [HY000]: General error: 1 Can't create / write to file '/tmp/#sql_3f0_0.MYD' (Errcode: 28)

I understand that the folder / tmp is clogged. And restarting the VPS does not help. Only rm -r /tmp .

Can you somehow regulate this behavior to prevent the site from falling?

 root@185:/home/admin# df -h Filesystem Size Used Avail Use% Mounted on /dev/xvda3 29G 21G 6.1G 78% / none 4.0K 0 4.0K 0% /sys/fs/cgroup udev 492M 4.0K 492M 1% /dev tmpfs 101M 384K 100M 1% /run none 5.0M 0 5.0M 0% /run/lock none 501M 0 501M 0% /run/shm none 100M 0 100M 0% /run/user /dev/xvda1 190M 184M 0 100% /boot root@185:/home/admin# df -h tmp Filesystem Size Used Avail Use% Mounted on /dev/xvda3 29G 21G 6.1G 78% / root@185:/home/admin# 

from comment:

 $ stat -c '%A' /tmp drwxrwxrwx 
  • and what does $ stat -c '%A' /tmp ? - aleksandr barakin
  • Throws drwxrwxrwx - LANSELOT

1 answer 1

$ stat -c '% A' / tmp
drwxrwxrwx

this is wrong for the /tmp . from man chmod :

deletion flag for the directory

add the flag restricted deletion :

 $ sudo chmod +t /tmp 

I'm not sure that this is exactly the problem, but the words about “only removing /tmp ” help and the lack of mention of how the catalog is recreated “hooked”.


In general, I would recommend to start with monitoring the free space on the partition where the /tmp directory is located to identify the problem. somehow (a line with the date and output of the df program is added to the file ~/mm every half an hour):

 $ while true; do sleep 1800; { echo -n "$(\date) "; df /tmp | tail -n 1; } >> ~/mm; done 

This command is better, of course, to run in the screen session (or tmux ), so that it is not interrupted when the connection with the server is lost.