LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   PHP file initiated by rc.local halted server and killed it (https://www.linuxquestions.org/questions/linux-newbie-8/php-file-initiated-by-rc-local-halted-server-and-killed-it-4175604868/)

NotionCommotion 04-28-2017 09:57 AM

PHP file initiated by rc.local halted server and killed it
 
I was ssh'd into my server, and witnessed the following. Why did it halt? cron.php which will execute every 5 seconds will write to a database, but doesn't do anything to cause the server to halt.

Code:

login as: Michael
Michael@10.120.11.10's password:
Last login: Fri Apr 28 06:16:32 2017 from 10.120.11.123
[Michael@devserver ~]$ ps aux | grep php
root      3980  0.1  0.1 354168 15660 ?        S    06:55  0:00 /usr/bin/php /v                                                                                                                                                            ar/www/datalogger/server.php
Michael  4050  0.0  0.0 103332  852 pts/1    S+  06:55  0:00 grep php
[Michael@devserver ~]$ cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
/usr/local/include/connect_wifi

/usr/local/bin/test_soap
exit 0
[Michael@devserver ~]$ cat /usr/local/bin/test_soap
# Initiate a given PHP file every 5 seconds.

while true
do
 /usr/bin/php /var/www/soap_server/cron.php &
 sleep 5
done
exit 0
[Michael@devserver ~]$ sudo /etc/init.d/test_soap start
[sudo] password for Michael:
# Initiate a given PHP file every 5 seconds.

while true
do
 /usr/bin/php /var/www/soap_server/cron.php &
 sleep 5
done
exit 0
Starting service…
Service started
[Michael@devserver www]$
Broadcast message from root@devserver.michaels.lan
        (unknown) at 7:11 ...

The system is going down for halt NOW!

Then I went to the physical machine, and it was attempting to boot, but hung up on initiating the certmonger process. I turned off the machine and then turned it on, and witness the following (not per verbatim, and caps are my notes to you)

ON
Code:

ALL LOOKING GOOD
....
Mounting local filesystems.  Mount point 0 does not exist. (AND SOME OTHER TEXT)
....
Unicorn failed  (I THINK IT ALWAYS HAS FAILED)
Starting Cert Monger (HANGS INDEFINITELY)

OFF
Code:

ALL LOOKING GOOD
....
Unmounting file system
/home device is busy (AND SOME OTHER TEXT)
....
TURNS OFF

Any thoughts why it happened, and how to fix it?

NotionCommotion 04-28-2017 11:09 AM

Was able to boot the machine off of a usb, edited rc.local, and all is good. Still curious what was going on. Any ideas???

r3sistance 04-28-2017 11:11 AM

Maybe strace Cert Monger or see if it has any log files, can not really tell you why something is hanging with no real details.

NotionCommotion 04-28-2017 11:23 AM

Quote:

Originally Posted by r3sistance (Post 5703604)
Maybe strace Cert Monger or see if it has any log files, can not really tell you why something is hanging with no real details.

Understood regarding the lack of details. I am 99% sure it had nothing to do with certmonger, however. After editing rc.local and rebooting, I am pretty sure that was the last process to show up on the screen, thus rc.local must have come next. Maybe because /usr/local/bin/test_soap in rc.local wasn't run in the background?

NotionCommotion 04-28-2017 11:48 AM

Still don't know exactly what happened, but as seen I was running php as root. Definitely not a good idea!

michaelk 04-28-2017 12:57 PM

Scripts running from rc.local do run as root.
Code:

while true
do
 /usr/bin/php /var/www/soap_server/cron.php &
 sleep 5
done

Code:

/usr/local/bin/test_soap
Correct. While the command that calls your php script goes to the background your main script that runs from rc.local does not which appears to hang the computer.

AwesomeMachine 04-28-2017 06:31 PM

You can fix that by putting "space&" after the command to set it into the background.


All times are GMT -5. The time now is 07:04 PM.