#1 (permalink)  
Old 03-14-2008, 10:28 PM
majoosh's Avatar
Registered User
 
Join Date: Feb 2006
Location: India
Posts: 84
majoosh is on a distinguished road
"Warning: Unknown(): Failed to write session data (files)"

Hi guys,

Am getting the following error in our server:

========================================
Warning: session_register(): open(/tmp/sess_65cd921b8ba993f3c437e02daa315e68, O_RDWR) failed: No such file or directory (2) in /home/bla/public_html/admin/index.php on line 1

Warning: session_register(): Cannot send session cookie - headers already sent by (output started at /home/bla/public_html/admin/index.php:1) in /home/bla/public_html/admin/index.php on line 1

Warning: session_register(): Cannot send session cache limiter - headers already sent (output started at /home/bla/public_html/admin/index.php:1) in /home/bla/public_html/admin/index.php on line 1
Warning: Unknown(): open(/tmp/sess_65cd921b8ba993f3c437e02daa315e68, O_RDWR) failed: No such file or directory (2) in Unknown on line 0

Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0
=====================================


Also I have seen so many thread opened in forum regarding the same issue without any resolution


It's not any problem with /tmp permission. Here are the permission and df -h results for my server
===========
root [/tmp]# df -h
/usr/tmpDSK 484M 14M 445M 3% /tmp
/tmp 484M 14M 445M 3% /var/tmp
=========
==========
root[/tmp]# mount
/dev/hda3 on / type ext3 (rw)
none on /proc type proc (rw)
usbdevfs on /proc/bus/usb type usbdevfs (rw)
/dev/hda1 on /boot type ext3 (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/hde2 on /home type ext3 (rw,usrquota)
none on /dev/shm type tmpfs (rw,noexec,nosuid)
/usr/tmpDSK on /tmp type ext3 (rw,noexec,nosuid,loop=/dev/loop0)
/tmp on /var/tmp type none (rw,noexec,nosuid,bind)
=============

============
root[/tmp]# php -v
PHP 4.4.2 (cgi) (built: Jun 10 2006 04:53:36)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
with Zend Extension Manager v1.0.6, Copyright (c) 2003-2004, by Zend Technologies
============

I have checked all possibilities mount, /tmp permission , php.ini ....but no clue

session.save_path is /tmp in php.ini

Am using old version of easyapache...and not using phpsuexec

I have tried wiping the session files and the issue is fixed temperaroly but everytime I have to do this when customer reports this and that's going to be a real pain

As per instruction from a cpanel guy I have set "session.bug_compat_42 = Off" (without the quotes) in php.ini file and restart apache and didn't do any trick

This started recently ..... Any idea if cpanel did any updates recently ???


Thanks
Mojo
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-16-2008, 09:01 AM
serversphere's Avatar
Registered User
 
Join Date: Jan 2004
Posts: 652
serversphere is on a distinguished road
Quote:
Originally Posted by majoosh View Post
Warning: session_register(): Cannot send session cookie - headers already sent by (output started at /home/bla/public_html/admin/index.php:1) in /home/bla/public_html/admin/index.php on line 1
Mojo, is your /tmp directory simply getting overrun with SESS files? If so, try this:

make a file in scripts called cleantmp, put the following in it:
Code:
# This script cleans out /tmp of empty, root, cpanel
# and nobody session files in /tmp
# rev 2.0b by Darren - 8.19.07

# if --test is passed, we just show the results
if [ "$1" == "--test" ]
then
        CMD="-exec ls -la"
        echo "$0: test mode"
else
        CMD="-exec rm -rf"
fi

if [ "$1" == "--help" ]
then
        echo ""
        echo "cleantmp will clean out your tmp directory for you"
        echo ""
        echo "Parameters:"
        echo "--test            to run in test mode"
        echo "--help            display this file"
        echo "-a accountname    to remove all files owned by account name"
        echo "-e                cleans out all empty (zero length) files"
        echo ""
        exit 0
fi

if [ "$1" == "-a" ]
then
        echo ""
        echo "Removing session file for account $2"
        find /tmp -name "sess*" -user $2 -maxdepth 1 $CMD {} \;
        echo "completed"
        echo ""
        exit 0
fi

if [ "$1" == "-e" ]
then
        echo ""
        echo "Cleaning out empty files from /tmp"
        find /tmp -name "sess*" -empty -maxdepth 1 $CMD {}  \;
        echo "completed"
        echo ""
        exit 0
fi


# remove empty session files that are over 2 hours old
find /tmp -name "sess*" -empty -mmin +120 -maxdepth 1 $CMD {}  \;

# remove root owned session files
find /tmp -name "sess*" -user root -maxdepth 1 $CMD {} \;

# remove nobody session files
find /tmp -name "*sess*" -user nobody -maxdepth 1 $CMD {} \;

# remove cpanel owned session files
find /tmp -name "sess*" -user cpanel -maxdepth 1 $CMD {} \;

# remove any session file over 5 hours old
find /tmp -name "sess*" -mmin +300 -maxdepth 1 $CMD {} \;

# remove any spamassassin file over 4 hours old
find /tmp -name ".spamassassin*" -mmin +240 -maxdepth 1 $CMD {} \;
Now save, and chmod it so it can be run (use your discretion for perm level):
chmod 755 /scripts/cleantmp

Run it as /scripts/cleantmp --test to view which files will be removed or /scripts/cleantmp -a accountname to remove all files owned by account name. And running it with "-e" will remove all empty session files.

What we do on most boxes is have it run in cron.hourly so that it purges session files. It cleans empties that are over 2 hours old, and normal ones that are over 5 hours old. Keep in mind, this may break software that uses "Keep Me Logged In Indefinitely" option for users. But the script could be easily modified to skip some session files if needed.

So, go to /etc/cron.hourly and create a file called cleantmp. Put this into it:
Code:
#!/bin/bash

/scripts/cleantmp -e >/dev/null 2>&1
/scripts/cleantmp >/dev/null 2>&1
and save it, then do the same permissions procedure as above. Now every hour, the script wil clean out empty and older SESS files and keep your sites up. Modify this and the other script as needed.

Hope this helps!
__________________
Darren Benfer | SS-Darren | AIM: serversphere
www.serversphere.com
Dedicated Server Solutions Have Come Full Circle
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-17-2008, 08:10 AM
majoosh's Avatar
Registered User
 
Join Date: Feb 2006
Location: India
Posts: 84
majoosh is on a distinguished road
Hi serversphere,

You RoCk!!!! but a server reboot fixed the problem


Thanks
Mojo
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-18-2008, 10:46 AM
majoosh's Avatar
Registered User
 
Join Date: Feb 2006
Location: India
Posts: 84
majoosh is on a distinguished road
The error poped up again . server reboot is not good solution ...


What's causing this error ? any idea ?


Mojo
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-18-2008, 11:02 AM
majoosh's Avatar
Registered User
 
Join Date: Feb 2006
Location: India
Posts: 84
majoosh is on a distinguished road
session.gc_maxlifetime=1440 that will do the trick

Thanks
Mojo
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-27-2008, 09:38 PM
majoosh's Avatar
Registered User
 
Join Date: Feb 2006
Location: India
Posts: 84
majoosh is on a distinguished road
Still having problem ... and I see the error kernel: EXT3-fs error (device loop(7,0)): ext3_readdir: bad entry in directory in /var/log/messeges


Any idea ?

Majoosh
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-27-2008, 11:46 PM
Registered User
 
Join Date: Aug 2007
Posts: 53
nerbonne is on a distinguished road
Are you using temporary urls to access the sites? The only time I have session problems is when I use the temp urls. The first site is ok, but the second site I try to go to on the same server causes a problem. This will only occur on a CGI server. The reason is that your session is owned by user one, so user two can't write to it.

Understand?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-29-2008, 02:32 AM
majoosh's Avatar
Registered User
 
Join Date: Feb 2006
Location: India
Posts: 84
majoosh is on a distinguished road
But why the error error kernel: EXT3-fs error (device loop(7,0)): ext3_readdir: bad entry in directory ?



Majoosh
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 11-20-2008, 08:38 AM
majoosh's Avatar
Registered User
 
Join Date: Feb 2006
Location: India
Posts: 84
majoosh is on a distinguished road
I rebuild /tmp and that fixed all the problem


Majoosh
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 05-23-2009, 02:05 AM
Registered User
 
Join Date: May 2009
Posts: 5
donneo2000 is on a distinguished road
Mojo.. thanx for posting the solution
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #11 (permalink)  
Old 02-22-2010, 05:58 AM
Registered User
 
Join Date: May 2009
Posts: 5
donneo2000 is on a distinguished road
rebuilding /tmp will not fix the issue always. You may need to do the following as a permanent fix:

touch /var/cpanel/usecpphp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:13 PM.


Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
© cPanel Inc