0

I'm getting email errors from a cron, on Ubuntu, that lives at:

/etc/cron.d/php5

I didn't install that cron, so I'm guessing it is installed with PHP. Its contents are as follows:

# /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/ -depth -mindepth 1 -maxdepth 1 -type f -cmin +\
$(/usr/lib/php5/maxlifetime) -delete

It seems to be the cron that kills old sessions.

It is however, sending me this email error:

To: root

Subject: Cron <root@mailserver> [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete (failed)

Message:
PHP Fatal error:  Allowed memory size of 262144 bytes exhausted (tried to allocate 523800 bytes) in Unknown on line 0
find: invalid argument `-delete' to `-cmin'

Does anyone know how to go about remedying this?

EDIT: I know that 262144 bytes is not very much, so perhaps I should just bump up the memory limit? I figure that is a workaround, but I was just curious as to why these errors suddenly started popping up. There are never actually any $_SESSIONs created on this server, it's only used to send email.

6
  • 1
    The problem is almost certainly related to the /usr/lib/php5/maxlifetime script being called. What happens when you run that manually? How are you running PHP on your system? Are you using mod_php, cgi, fcgi, or something else? Anyway, look at that script, and figure out where it is breaking.
    – Zoredache
    Feb 13, 2012 at 19:49
  • @Zoredache: I'm running it through cron triggered PHP scripts, so cli. And that file is a shell script, with this line causing an immediate error: php5 -c /etc/php5/apache2/php.ini -r 'print ini_get("session.gc_maxlifetime");'
    – Josh
    Feb 13, 2012 at 19:56
  • @Zoredache: Weird. -c specifies the .ini file. In that file, I have memory_limit = 1024MB, and running just: php5 -c /etc/php5/apache2/php.ini -r 'echo "here";' causes the same error, PHP Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 523800 bytes) in Unknown on line 0 Could not startup.
    – Josh
    Feb 13, 2012 at 19:59
  • @Zoredache: And that's the error. It was set to 1024MB, instead of 1024M. The value was illegal. Since I don't run it as an Apache module, I never knew. I'll just update maxlifetime.sh to use the cli config. Thanks!
    – Josh
    Feb 13, 2012 at 20:01
  • Since you solved your problem, you should add an answer, and accept it.
    – Zoredache
    Feb 13, 2012 at 20:06

1 Answer 1

1

My issue was in the way the Apache2 version of my .ini file was configured. It was set to allow for 1024MB of memory, rather than the correct 1024M. Someone else must have been messing around in it, since I'm only using PHP on this server via CLI.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .