基于 Debian 的系统会话在特殊 cron 中在 30 分钟时被杀死,如何覆盖? [英] Debian based systems Session killed at 30 minutes in special cron, how to override?

查看:26
本文介绍了基于 Debian 的系统会话在特殊 cron 中在 30 分钟时被杀死,如何覆盖?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一直在拔我的头发,试图找出为什么我的会话在 30 分钟时被终止/杀死/破坏.好吧,看起来基于 Debian 的系统有一个特殊的 cron 正在运行,它会忽略所有 php.ini 和 apache 配置并在 30 分钟时终止任何空闲会话.

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.

cron 路径:/etc/cron.d/php5

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

我不擅长配置和设置主机,但我不是系统管理员.有人可以帮我覆盖/编辑/更改/重新配置它,以便我可以将值设置得更久吗?我认为 3 小时会很好,但我想了解更改,因此如果更高级别的人想要缩短/更长的会话时间,我会记录如何配置更改.

I'm not bad at configuring and setting up hosts but I'm no sysAdmin. Could someone please help me override/edit/change/reconfigure this so I can set the value longer? I think 3 hours would be nice but I would like to understand the changes so if someone higher up wants to make the session time shorter/longer I con document how to configure the change.

感谢对此的任何见解帮助

Thanks to any insight help on this

添加/usr/lib/php5/maxlifetime 代码

Adding /usr/lib/php5/maxlifetime code

#!/bin/sh -e

max=1440

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
done

echo $(($max/60))

exit 0

因此它看起来正在搜索所有 php.ini 文件,找到最大值,将其与 1440(即 24 分钟)进行比较.

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

这里是 php.ini 文件

Here are the php.ini files

/etc/php5/apache2/php.ini
session.gc_maxlifetime = 1440 

/etc/php5/cgi/php.ini
session.gc_maxlifetime = 1440

/etc/php5/cli/php.ini
session.gc_maxlifetime = 1440

但是为什么我的脚本会话在 30 分钟而不是 24 分钟时被终止?

but why does my script session get killed at 30 minutes and not 24 minutes?

编辑#2:CRON 每 30 分钟运行一次,这就是会话看起来每隔 30 分钟被终止的原因.但也可能是 24 到 54 分钟,仅供参考

EDIT #2: 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

同时查看以下代码:/usr/lib/php5/maxlifetime 它采用了最高值,在我的测试期间,我试图降低阈值以加快条件.

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.

看起来我只需要在 php.ini 文件上增加一个就可以超过一个小时的测试测试.

Looks like I just need to increase one on the php.ini files to over one hour test test.

推荐答案

编辑文件 /usr/lib/php5/maxlifetime

该值应以秒为单位.该文件实际上还会检查您的 php.ini,所以我不知道为什么它对您不起作用.

The value should be in seconds. This file will actually also check your php.ini so I don't know why it wasn't working for you.

这篇关于基于 Debian 的系统会话在特殊 cron 中在 30 分钟时被杀死,如何覆盖?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆