Posted on February 16, 2017 at 12:50 am
Use “df -i” command to view inodes usage:
Filesystem Inodes IUsed IFree IUse% Mounted on /dev/sda2 1310720 1310720 0 100% / |
That means you ran out of inodes! Most probably PHP sessions are the issue.
A quick command to delete all sess_* files on /var/lib/php/sessions is this:
find /var/lib/php/sessions -type f -cmin +24 -name "sess_*" -exec rm -f {} \; |
But I would recommend you to use a bash script, keep reading below:
On your PHP.ini file you should see something like this:
; After this number of seconds, stored data will be seen as 'garbage' and ; cleaned up by the garbage collection process. session.gc_maxlifetime = 1440 ; NOTE: If you are using the subdirectory option for storing session files ; (see session.save_path above), then garbage collection does not ; happen automatically. You will need to do your own garbage ; collection through a shell script, cron entry, or some other method. |
That means you need to clean the PHP sessions by yourself with a script.
Here is a bash script that can be used to delete PHP sessions:
#!/bin/bash # Export bin paths export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # Get PHP Session Details PHPSESSIONPATH=$(php -i 2>/dev/null | grep -w session.save_path | awk '{print $3}' | head -1); PHPSESSIONLIFETIME=$(php -i 2>/dev/null | grep -w session.gc_maxlifetime | awk '{print $3}' | head -1); PHPSESSIONLIFETIMEMINUTE=$( expr $PHPSESSIONLIFETIME / 60 ); # If PHPSESSIONPATH exists if [ -d $PHPSESSIONPATH ]; then # Find and delete "expired" sessions find $PHPSESSIONPATH -type f -cmin +$PHPSESSIONLIFETIMEMINUTE -name "sess_*" -exec rm -f {} \; fi |
Original script can be found here:
Script to delete PHP session files to keep inode usage to minimum
Then you need to add this to /etc/crontab to run the script every hour:
# Delete PHP sessions 0 * * * * root /root/clean-php-session-files.sh >/dev/null 2>&1 |
Other Posts
- Detect VMWare Virtual Machine
- Detect Microsoft Virtual PC Virtual Machine
- Fix MariaDB 10.5 "Can't create test file" errors
- Use MariaDB and MySQL without Password (MySQL Backup)
- Check if a Trademark is already registered
- Make name server address permanent in /etc/resolv.conf
- InnoSetup error the servicemanager is not available
- InnoSetup disable DesktopIcon via command-line
Updated Posts
- Use cURL to check for SSL certificate issues:
- How to test Socks5 proxy with cURL
- How to use variables in a sed command
- Best Socks5 Servers for Linux Debian
- Error NO_PUBKEY in Google Cloud Debian Packages Update
- How to Run a Command with Time Limit in Bash Linux
- MySQL InnoDB log sequence number is in the future
- Download CSV Top 1 Million Websites by Popularity