PHP script causes server shutdown

John asked:

I have a centos server with 4Gb RAM. I’m doing a PHP console batch process that may take some hours… however it doesn’t finish as the server shutdown after 1 or 2 hours from lauching the process… Here are the logs:

    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.

It starts the clean php session files then suddently stops all services and shuts down!

My code seems ok….do I need to force cleaning the variables on code?

What is the problem?

Thanks

My answer:


Your log shows that some process sent a signal to systemd causing it to shut down, and that the name of the process was kill.

Dec 28 04:40:04 www systemd[24724]: Received SIGRTMIN+24 from PID 11820 (kill).

It’s most likely that a user did this manually, or that a script running on the system sent a signal to PID 1 (possibly by mistake, intending some other PID).

You may want to look into the two root user sessions that were open at the time of the shutdown.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.