Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Sat Feb 09, 2013 5:27 pm 
Offline
Senior Newbie

Joined: Sat Mar 20, 2010 6:30 pm
Posts: 11
After an upgrade to the system (Debian 6 Squeeze running dotdeb) the other day, I started getting a cron error message every 30 minutes.

The subject of the email is:
Cron <root@francis> [ -x /usr/lib/php5/maxlifetime ] && [ -x /usr/lib/php5/sessionclean ] && [ -d /var/lib/php5 ] && /usr/lib/php5/sessionclean /var/lib/php5 $(/usr/lib/php5/maxlifetime) (failed)

And the body of the message is simply:
find: invalid argument `-delete' to `-cmin'

I'm running PHP 5.4.11-1~dotdeb.0. The contents of maxlifetime are:

#!/bin/sh -e

max=1440

if which php5 >/dev/null 2>&1; then
for sapi in apache2 apache2filter cgi fpm; do
if [ -e /etc/php5/${sapi}/php.ini ]; then
cur=$(php5 -c /etc/php5/${sapi}/php.ini -d "error_reporting='~E_ALL'" -r 'print ini_get("session.gc_maxlifetime");')
[ -z "$cur" ] && cur=0
[ "$cur" -gt "$max" ] && max=$cur
fi
done
else
for ini in /etc/php5/*/php.ini /etc/php5/conf.d/*.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
done
fi

echo $(($max/60))

exit 0

I'm kind of at a loss as to what to do. Any pointers would be greatly appreciated. Thanks!


Top
   
PostPosted: Sat Feb 09, 2013 5:43 pm 
Offline
Senior Member
User avatar

Joined: Wed Mar 17, 2004 4:11 pm
Posts: 554
Website: http://www.unixtastic.com
Location: Europe
Find in being run without an argument to -cmin, It looks like either sessionclean or something sessionclean runs doesn't have a variable set and doesn't do enough checking.

If you run /usr/lib/php5/maxlifetime do you get a number?


Top
   
PostPosted: Sat Feb 09, 2013 5:58 pm 
Offline
Senior Newbie

Joined: Sat Mar 20, 2010 6:30 pm
Posts: 11
I get nothing when I run /usr/lib/php5/maxlifetime

Is there a way to remedy this?


Top
   
PostPosted: Sat Feb 09, 2013 6:13 pm 
Offline
Senior Member
User avatar

Joined: Wed Mar 17, 2004 4:11 pm
Posts: 554
Website: http://www.unixtastic.com
Location: Europe
Ok, that's likely the problem then.

Do any of the following files exist?
/etc/php5/apache2/php.ini
/etc/php5/apache2filter/php.ini
/etc/php5/cgi/php.ini
/etc/php5/fpm/php.ini


It looks like session.gc_maxlifetime should be set in one or more of the above files. I have this set in apache2/php.ini, cli/php.ini, fpm/php.ini. In all cases in line looks like:
session.gc_maxlifetime = 1440


Top
   
PostPosted: Sat Feb 09, 2013 10:53 pm 
Offline
Senior Newbie

Joined: Sat Mar 20, 2010 6:30 pm
Posts: 11
Thanks. I looked at those files. The only existing file was /etc/php5/apache2/php.ini and it actually did have session.gc_maxlifetime = 1440. I looked for other cases of php.ini and any version I found also had that variable with that value. Checking /usr/lib/php5/maxlifetime still returns no value.

Here are the contents of sessionclean:

#!/bin/sh

# first find all used files and touch them (hope it's not massive amount of files)
lsof -w -l +d "${1}" | awk -- '{ if (NR > 1) { print $9; } }' | xargs -i touch -c {}

# find all files older then maxlifetime
find "${1}" -depth -mindepth 1 -maxdepth 1 -type f -ignore_readdir_race -cmin +${2} -delete

Looking at the script, it looks like it has no value for ${2} – what is it expecting there?


Top
   
PostPosted: Sun Feb 10, 2013 1:41 pm 
Offline
Senior Member
User avatar

Joined: Wed Mar 17, 2004 4:11 pm
Posts: 554
Website: http://www.unixtastic.com
Location: Europe
shadyhill wrote:
Thanks. I looked at those files. The only existing file was /etc/php5/apache2/php.ini and it actually did have session.gc_maxlifetime = 1440. I looked for other cases of php.ini and any version I found also had that variable with that value. Checking /usr/lib/php5/maxlifetime still returns no value.

Here are the contents of sessionclean:

#!/bin/sh

# first find all used files and touch them (hope it's not massive amount of files)
lsof -w -l +d "${1}" | awk -- '{ if (NR > 1) { print $9; } }' | xargs -i touch -c {}

# find all files older then maxlifetime
find "${1}" -depth -mindepth 1 -maxdepth 1 -type f -ignore_readdir_race -cmin +${2} -delete

Looking at the script, it looks like it has no value for ${2} – what is it expecting there?


The command was:
/usr/lib/php5/sessionclean /var/lib/php5 $(/usr/lib/php5/maxlifetime)

$2 is the output of /usr/lib/php5/maxlifetime


maxlifetime really should be returning something, I don't see why it isn't. You could try deleting the line containing 'session.gc_maxlifetime = 1440' from php.ini and copy and pasting it from this message, just in case there is some whitespace problem that causes the script to fail.


Top
   
PostPosted: Sun Feb 10, 2013 11:42 pm 
Offline
Senior Newbie

Joined: Sat Mar 20, 2010 6:30 pm
Posts: 11
Still no luck. I did some more digging on the PHP install, and it looks like the version of php.ini that is being processed is /etc/php5/cli/php.ini

Again, if I'm reading the sessionclean script correctly (and I'm not convinced I am), it's not looking for a value in cli/php.ini.

However, the gc_maxlifetime = 1440 is present in both the cli/php.ini and the apache2/php.ini and maxlifetime refuses to output anything. Is the php.ini file really the culprit, or should I being paying more attention to the maxlifetime issue?


Top
   
PostPosted: Mon Feb 11, 2013 6:53 pm 
Offline
Senior Member
User avatar

Joined: Tue Apr 13, 2004 6:54 pm
Posts: 833
shadyhill wrote:
should I being paying more attention to the maxlifetime issue?

Change the "#!/bin/sh -e" to "#!/bin/sh -x" to see what's going on. There's likely to be a syntax error that the "-e" is hiding. (The fact that it's using "bash" type syntax with "/bin/sh" is just silly, but may not be the problem).

_________________
Rgds
Stephen
(Linux user since kernel version 0.11)


Top
   
PostPosted: Mon Feb 11, 2013 11:00 pm 
Offline
Senior Newbie

Joined: Sat Mar 20, 2010 6:30 pm
Posts: 11
Ah ha! Thank you. That did it. The output of maxlifetime showed a Fatal error: Fatal error: Directive 'register_long_arrays' is no longer available in PHP in Unknown on line 0

This was turned off in /etc/php5/cli/php.ini, but was still in place in /etc/php5/apache2/php.ini

I uncommented the line, and now maxlifetime outputs a value of 24. Hopefully cron will run smoothly now.

Thanks for all the help!


Top
   
PostPosted: Tue Feb 12, 2013 11:15 am 
Offline
Senior Member
User avatar

Joined: Tue Apr 13, 2004 6:54 pm
Posts: 833
Remember to set back the #!/bin/sh line :-)

_________________
Rgds

Stephen

(Linux user since kernel version 0.11)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group