CageFS makes sure that each user has his own /tmp directory, and that directory is the part of end-user's quota.
The actual location of the directory is $USER_HOME/.cagefs/tmp
Once a day, using cron job, CageFS will clean up user's /tmp directory from all the files that haven't been accessed during 30 days.
This can be changed by running:
Where 720 is the number of hours that the file had to be inaccessible to be removed.
By default this is done at 03:37 AM, but you can also force the clean up outdated files that match 'chosen period' of all user's /tmp directories without waiting for a job to be launched by cronjob. Just run:
$ cagefsctl --tmpwatch
The following path will be cleaned as well:
/var/cache/php-eaccelerator (actual location $USER_HOME/.cagefs/var/cache/php-eaccelerator)
You can configure tmpwatch to clean custom directories inside CageFS.
Create /etc/cagefs/cagefs.ini configuration file and specify tmpwatch_dirs directive as follows:
After that directories /dir1 and /dir2 inside CageFS will be cleaned automatically.
Note that actual location of those directories in real file system is $USER_HOME/.cagefs/dir1 and $USER_HOME/.cagefs/dir2.
Cleanup of PHP sessions
For cPanel servers, CageFS version 6.0-42 or higher performs cleaning of PHP sessions based on session.gc_maxlifetime and session.save_path directives specified in proper php.ini files.
session.gc_maxlifetime directive default value is 1440 seconds. Those session files will be deleted, that were created or had metadata (ctime) changes more time ago than it is specified in session.gc_maxlifetime.
For Alt-PHP versions session.save_path value is normally /tmp.
Note. For new installations of Alt-PHP packages, session.save_path will be changed from /tmp to /opt/alt/phpNN/var/lib/php/session, where NN corresponds to Alt-PHP version.
This applies to the following Alt-PHP versions (or later):
When using EasyApache 3, session.save_path value is normally /var/cpanel/php/sessions/ea3 or /tmp. Seettings for EasyApache 3 are usualy taken from the file /usr/local/lib/php.ini.
When using EasyApache 4, session.save_path value is normally /var/cpanel/php/sessions/ea-phpXX, where XX corresponds to PHP version.
Cleaning is started by cron /etc/cron.d/cpanel_php_sessions_cron, which starts the script /usr/share/cagefs/clean_user_php_sessions twice within one hour.
The settings are located in /opt/cpanel/ea-phpXX/root/etc/php.d/local.ini or in /opt/cpanel/ea-phpXX/root/etc/php.ini, where XX corresponds to PHP version.
The settings for ea-php are located in /opt/cpanel/ea-phpXX/root/etc/php.d/local.ini or in /opt/cpanel/ea-phpXX/root/etc/php.ini, where XX corresponds to PHP version.
The settings for alt-php are located in /opt/alt/phpXX/etc/php.ini files, where XX corresponds to PHP version.
The cleaning script cleans php sessions for all PHP versions (ea-php and alt-php) regardless of whether a version is used or selected via MultiPHP Manager or PHP Selector. When different session.gc_maxlifetime values are specified for the same session.save_path (for different php versions), the cleaning script will use the least value for cleaning session.save_path. So, it is recommended to specify different session.save_path for each PHP version.
Users can define custom value of session.gc_maxlifetime via PHP Selector in order to configure PHP's garbage collector, but that will not affect the script for cleaning php sessions.
Cleanup of PHP session files in Plesk
For Plesk servers, CageFS version 6.0-52 or higher is provided with a special cron job for removing obsolete PHP session files. Cleanup script runs once an hour (similar to how it is done in Plesk).
Each time the script runs, it performs the cleanup of the paths:
1. set by session.save_path directive in /opt/alt/phpXX/etc/php.ini files. If session.save_path is missing, then /tmp is used. Session files lifetime is set by session.gc_maxlifetime directive. If it is not found, then 1440 seconds value is used (24 minutes, as in Plesk). Lifetime set in the file is only taken into consideration if it is longer than 1440 seconds, otherwise 1440 seconds is used. All the installed Alt-PHP versions are processed.
2. /var/lib/php/session. Files lifetime is only defined by Plesk script /usr/lib64/plesk-9.0/maxlifetime. If the script is missing or returns errors, then this directory is not processed.
The following features are applied during the cleanup:
•all the users with UID higher than specified in /etc/login.defs are processed. Each user is processed independently from one another.
•only directories inside CageFS are being cleaned. The paths of the same name in the physical file system are not processed.
•in all the detected directories, all the files with the names that correspond to sess_* search mask are removed, the rest of the files are ignored.
•the files older than specified lifetime are removed.
•all non-fatal errors (lack of rights, missing directory) are ignored and do not affect the further work of the script.