Solved

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

Posted on 2014-04-10
9
2,667 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
The viewer will learn how to dynamically set the form action using jQuery.

729 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