Cron Error every 30 minutes related to recent upgrade?

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 [ -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 "errorreporting='~EALL'" -r 'print iniget("session.gcmaxlifetime");')

[ -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!

9 Replies

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?

I get nothing when I run /usr/lib/php5/maxlifetime

Is there a way to remedy this?

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

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 -ignorereaddirrace -cmin +${2} -delete

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

@shadyhill:

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 -ignorereaddirrace -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.

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?

@shadyhill:

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).

Ah ha! Thank you. That did it. The output of maxlifetime showed a Fatal error: Fatal error: Directive 'registerlongarrays' 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!

Remember to set back the #!/bin/sh line :-)

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct