LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-28-2017, 09:57 AM   #1
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 789

Rep: Reputation: Disabled
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?
 
Old 04-28-2017, 11:09 AM   #2
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 789

Original Poster
Rep: Reputation: Disabled
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???
 
Old 04-28-2017, 11:11 AM   #3
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
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.
 
Old 04-28-2017, 11:23 AM   #4
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 789

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by r3sistance View Post
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?
 
Old 04-28-2017, 11:48 AM   #5
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 789

Original Poster
Rep: Reputation: Disabled
Still don't know exactly what happened, but as seen I was running php as root. Definitely not a good idea!
 
Old 04-28-2017, 12:57 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 26,089

Rep: Reputation: 6046Reputation: 6046Reputation: 6046Reputation: 6046Reputation: 6046Reputation: 6046Reputation: 6046Reputation: 6046Reputation: 6046Reputation: 6046Reputation: 6046
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.
 
Old 04-28-2017, 06:31 PM   #7
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to: run bash file in Linux which is initiated from a Windows/Mac system adeoux Linux - General 4 04-28-2012 05:40 PM
Simple PHP script fails on local web server Azul Rondo Programming 2 08-08-2009 03:10 AM
a lot of http process initiated by the server itself??.. jaggy00 Linux - Server 2 06-29-2007 04:57 AM
Trouble viewing .php on local apache server using Mozilla shortname Linux - Software 2 03-25-2005 03:07 PM
no php.ini file under /usr/local/lib/ !! jogurt666 Linux - Software 1 12-16-2003 12:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration