Solved

Plesk PHP Session Cleanup unable to delete files from /var/lib/php/session

Posted on 2014-04-10
9
2,645 Views
Last Modified: 2014-04-16
I'm using 11.0.9 CentOS 6 110120608.16

All session files on my server are stored in the folder /var/lib/php/session

The folder has the following permissions set:

drwx-wx-wt 2 root root 548864 Apr 10 20:09 session

But all session files inside that folder only have rw permissions for there apache user exclusively

So I think the cron configured in /etc/cron.hourly/plesk-php-cleanuper is unable to actually perform the session cleanup, hence the size of the folder continues to grow and at this point every time the job runs and combs through all files the I/O weight goes to 100% and slows my entire server down to the point where the applications hosted on it are completely unaccessible.

How can I resolve this matter?
0
Comment
Question by:SWB-Consulting
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 25

Expert Comment

by:Zephyr ICT
ID: 39993767
I think you can set the rights on this folder as follows:

chmod 1777 /var/lib/php/session

Using sticky bit nobody can change the rights on this folder but the root user.
0
 

Author Comment

by:SWB-Consulting
ID: 39994372
OK, but how do I get the actual session files to be generated so they're accessible to the root user? Right now they are only generated with rw permissions to the apache user.
0
 
LVL 25

Expert Comment

by:Zephyr ICT
ID: 39994448
So the files get created with user apache:apache in rw? Is that the issue? I'm sorry, might have misunderstood ...

I'm assuming you already did the upgrade: http://kb.parallels.com/en/115704 ??
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

Author Comment

by:SWB-Consulting
ID: 39994541
No worries, yes I did that workaround on there. But I'm actually running PHP as module so not sure if that applies.

Yes, the problem seems to be that all session files are created with rw permission for ONLY the apache user. But the cleanup job is run under root.

Even when I try to remove a single file in that folder as root user it won't do it, it just finishes the delete command without any response and nothing has changed.
0
 
LVL 25

Expert Comment

by:Zephyr ICT
ID: 39994626
You can change the permissions on those file though, no?

chmod 777 /var/lib/php/session/*

or change the owner for all files in that directory first then run the script again for cleanup?

chown root:root /var/lib/php/session/*
0
 

Author Comment

by:SWB-Consulting
ID: 39994673
True, if I do it manually one time I could do that. But on an ongoing basis I have an automated job running that always tries to remove those files.

Or I could maybe just run the job as a crontab under the apache user.

I understand and appreciate your idea, but it strikes me as a bit of a patch/workaround. Everything that is in place right now is the way plesk seems to have it set by default, so I'm wondering if there isn't some way to get the session files saved with less restrictive permissions?

I can't be the only one on plesk with this issue (although I haven't found anyone with exactly this issue)
0
 

Author Comment

by:SWB-Consulting
ID: 39994683
This is the cronjob that plesk has created to cleanup sessions:

[ -x /usr/lib64/plesk-9.0/maxlifetime ] && [ -d /var/lib/php/session ] && find /var/lib/php/session -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib64/plesk-9.0/maxlifetime) ! -execdir fuser -s {} 2>/dev/null \; -delete

Open in new window

0
 

Accepted Solution

by:
SWB-Consulting earned 0 total points
ID: 39995715
Actually I figured it out: I changed the permissions from the officially prescribed Plesk ones (1733) to 733. Now the root user can delete files in that folder.
0
 

Author Closing Comment

by:SWB-Consulting
ID: 40003501
I found the problem.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Do not understand error message 3 45
Update Set Column Query Not Working as Expected 6 43
How can I split a variable 19 43
How can I send attachment with mail 5 22
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question