Monday, October 11, 2010

Ubuntu upgrading to 10.10 Apache hosts get overwritten

If anyone else goes through this just re-add your hosts to /etc/hosts and restart Apache, kept getting this error "(EAI 5)No address associated with hostname: Could not resolve host name".

Tuesday, October 05, 2010

Why are my PHP sessions timing out around 30 minutes?

Have been pulling out my hair trying to find out why my sessions are being terminated/killed/destroyed at 30 minutes. Well it looks like Debian based systems have a special cron running that ignores all php.ini and apache configurations and kills any idle session at 30 minutes.

The cron path: /etc/cron.d/php5

Inside the cron:

# /etc/cron.d/php5: crontab fragment for php5
# This purges session files older than X, where X is defined in seconds
# as the largest value of session.gc_maxlifetime from all your php.ini
# files, or 24 minutes if not defined. See /usr/lib/php5/maxlifetime

# Look for and purge old sessions every 30 minutes
09,39 * * * * root [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -type f -cmin +$(/usr/lib/php5/maxlifetime) -print0 | xargs -n 200 -r -0 rm

/usr/lib/php5/maxlifetime code

#!/bin/sh -e


for ini in /etc/php5/*/php.ini; do
cur=$(sed -n -e 's/^[[:space:]]*session.gc_maxlifetime[[:space:]]*=[[:space:]]*\([0-9]\+\).*$/\1/p' $ini 2>/dev/null || true);
[ -z "$cur" ] && cur=0
[ "$cur" -gt "$max" ] && max=$cur

echo $(($max/60))

exit 0

so it looks to be searching all the php.ini files, finds the greatest value, compares it to 1440 (which is 24 minutes).

Here are the php.ini files

session.gc_maxlifetime = 1440

session.gc_maxlifetime = 1440

session.gc_maxlifetime = 1440

CRON running every 30 minutes is why the session looks to be killed at 30 minute intervals. But it could also be 24 to 54 minutes, FYI

Also looking over the code in: `/usr/lib/php5/maxlifetime` it's taking the highest value and during my testing I was trying to lower the threshold to speed up the condition (this is why we were getting mixed results).

So to configure a higher number is easy, just configure one of the php.ini files, set session.gc_maxlifetime to a higher value than 1440 and you might want to also change the cron execution times.

If you wanted a lower number you would have to edit ALL the php.ini files on your system as welll as the /usr/lib/php5/maxlifetime max= variable to the smaller number

Thursday, June 17, 2010

My wifes iPhone 4 Pre-Order Story

So after the headache of ordering two iPhone 4's on June 15th Pre-Order day we finally got our email confirmations for a June 24the delivery (Yeah), but somehow in the process we ended up purchasing three iPhone's. (Wonder how this could have happen? Well the next day my wife calls to cancel one of the iPhone orders, the call took over two hours of being on hold (here is the funny part). During the on hold process my wife had to leave the house, not wanting to hang up (as she leaves the phone somewhere on speaker and listens for someone to pickup) she places the handset down and leaves the house for about forty minutes. Returning home she realizes she is still on hold with Apple and takes another ten minutes before she is able to speak to someone and resolve the issue, Great timing LOL!!! So to recap, two hours to speak to someone, forty minutes she leaves the house and just leaves the phone on speaker, an additional ten minutes on hold when she returns before speaking with someone. Priceless :)

Sunday, May 16, 2010

Pray for all involved

Yesterday I witnessed a horrific motorcycle accident. Don't know if the car hit the motorcycle or if it was the motorcycle hit the car, just saw the motorcycle hit the curb and the bike and rider smack into a lightpost. Jumped out of the car as my wife calls 911, I start yelling at the rider asking if he can hear me, I hear moaning. Others get out of their cars to help. I notice the driver of the car that hit the biker, she's early 20's and is in total shock, crying, shaking, unable to escape the situation she is now in. The rider is starting to move more but everyone is yelling at him to stay still, not move. Just below his knee his leg is bent at almost a 45 degree angle, blood is seeping through his jeans. I think his leg was smashed between the lightpost and the bike and his leg looks to be twisted. I'm about 2 feet away from him, he looks to be early 20's as well. A lone fireman who was just passing by stops to help and the police start to arrive and ask questions about the accident. The ambulance arrives and the EMT's start to stabilize the kid, cut up his jeans to see his leg that looks to be only attached by skin. They get him on the stretcher and as they are trying to load him in the ambulance, looks like his brother with friends and mother arrive. Pray for the two families as their lives are forever changed. As I think about the day which started off beautiful and the motorcycle rider going for a ride, the other driver maybe running some errands and my own family as we were headed to a friends daughters birthday party. How fragile life is and at a split second how it all can come grinding to a halt.