我有一台带有 4GB RAM 的 centos 服务器。我正在执行一个 PHP 控制台批处理,这可能需要几个小时……但是它没有完成,因为服务器在启动该过程 1 或 2 小时后关闭……以下是日志:
Dec 28 04:39:01 www systemd[1]: Starting Clean php session files...
Dec 28 04:39:02 www systemd[1]: Started Clean php session files.
Dec 28 04:40:04 www systemd[1]: Stopped target Mail Transport Agent.
Dec 28 04:40:04 www systemd[1]: Stopped target Timers.
Dec 28 04:40:04 www systemd[1]: Stopping User Manager for UID 0...
Dec 28 04:40:04 www systemd[1]: Stopping Session 12236053 of user root.
Dec 28 04:40:04 www systemd[1]: Stopped Daily apt upgrade and clean activities.
Dec 28 04:40:04 www systemd[24724]: Stopped target Default.
Dec 28 04:40:04 www systemd[24724]: Stopped target Basic System.
Dec 28 04:40:04 www systemd[24724]: Stopped target Sockets.
Dec 28 04:40:04 www systemd[24724]: Reached target Shutdown.
Dec 28 04:40:04 www systemd[24724]: Starting Exit the Session...
Dec 28 04:40:04 www systemd[24724]: Stopped target Timers.
Dec 28 04:40:04 www systemd[24724]: Stopped target Paths.
Dec 28 04:40:04 www systemd[1]: Stopping Session 12226070 of user root.
Dec 28 04:40:04 www systemd[1]: Stopped Run certbot twice daily.
Dec 28 04:40:04 www systemd[1]: Stopped Daily apt download activities.
Dec 28 04:40:04 www systemd[1]: Stopped Clean PHP session files every 30 mins.
Dec 28 04:40:04 www systemd[1]: Stopped Daily Cleanup of Temporary Directories.
Dec 28 04:40:04 www systemd[1]: Stopped target Graphical Interface.
Dec 28 04:40:04 www systemd[1]: Stopped target Multi-User System.
Dec 28 04:40:04 www systemd[1]: Stopped target Login Prompts.
Dec 28 04:40:04 www systemd[1]: Stopping Console Getty...
Dec 28 04:40:04 www systemd[1]: Stopping Getty on tty2...
Dec 28 04:40:04 www systemd[1]: Stopping LSB: modules.dep creation....
Dec 28 04:40:04 www systemd[1]: Stopping Unattended Upgrades Shutdown...
Dec 28 04:40:04 www systemd[1]: Stopping OpenBSD Secure Shell server...
Dec 28 04:40:04 www systemd[1]: Stopping LSB: Record successful boot for GRUB...
Dec 28 04:40:04 www systemd[1]: Stopping LSB: Start/stop sysstat's sadc...
Dec 28 04:40:04 www systemd[1]: Stopping A high performance web server and a reverse proxy server...
Dec 28 04:40:04 www systemd[1]: Stopping Regular background program processing daemon...
Dec 28 04:40:04 www systemd[1]: Stopping Runit service supervision...
Dec 28 04:40:04 www systemd[1]: Stopping D-Bus System Message Bus...
Dec 28 04:40:04 www systemd[24724]: Received SIGRTMIN+24 from PID 11820 (kill).
Dec 28 04:40:04 www systemd[1]: Stopping LSB: Starts or stops the xinetd daemon....
Dec 28 04:40:04 www systemd[1]: Stopping LSB: Postfix Mail Transport Agent...
Dec 28 04:40:04 www systemd[1]: Stopping The PHP 7.0 FastCGI Process Manager...
Dec 28 04:40:04 www systemd[1]: Stopping vsftpd FTP server...
Dec 28 04:40:04 www rsyslogd: [origin software="rsyslogd" swVersion="8.20.0" x-pid="370" x-info="http://www.rsyslog.com"] exiting on signal 15.
它启动清理的 php 会话文件然后突然停止所有服务并关闭!
我的代码看起来还好......我需要强制清理代码上的变量吗?
问题是什么?
谢谢
答案1
您的日志显示某个进程向 systemd 发送了信号导致其关闭,该进程的名称是kill
。
Dec 28 04:40:04 www systemd[24724]: Received SIGRTMIN+24 from PID 11820 (kill).
最有可能的是用户手动执行了此操作,或者系统上运行的脚本向 PID 1 发送了信号(可能是错误的,意图发送其他 PID)。
您可能需要查看关机时打开的两个根用户会话。
答案2
您似乎相当确定服务器关闭是运行脚本的结果。如果是这样,那么脚本就会关闭服务器。如果您不想让服务器关闭,请更改脚本。
另一方面,如果不是脚本出错,则说明发生了其他问题。提高日志记录级别。