Time to time we receive a complaint from managed VPS clients that they are not able to create session, they usually get an error some thing like
PHP Warning: Unknown: open(/tmp/sess_8974c0acd95c8d7ae09aa9222bb1acab, O_RDWR) failed: No space
Usually you can do the same old thing i.e. remove old files from /tmp. Usually deleting files older than 1 day is totally safe. Here is the command to do that.
find * -mtime +1 -exec rm {} \;
find command finds all files older than 1 day and pass it to rm which deletes them. Note there is space before and after {}. However if number of files in tmp are too much you will get this error.
/usr/bin/find: Argument list too long
To tackle argument too long issue, use it with “find .” instead of “find *”
The following commands worked good for me.
cd /tmp find . -mtime +1 | xargs rm -Rf`
and
find . -mtime +1 -delete
if you receive folder errors, add a file filter. The final command that you should use to delete x days old files in /tmp folder is
find /tmp/. -type f -mtime +1 -delete
update:
To remove files by access time use: atime
To remove files by status change (like name or attributes): ctime
To remove files by content modify time use (as used in this article): mtime