0

I have multiple php scripts running in my computer. I'd like to ask if there is any way to stop one php script and keep other scripts untouched?

Thank you very much!

Update: Sorry i assumed that most people are using Ubuntu/Linux.

Multiple php script is running in my Ubuntu OS laptop, each script is called by putting the link to my internet browser

3
  • what do you mean you have multiple scripts running on the computer? like on a browser running localhost? command line? Commented Aug 12, 2013 at 5:39
  • What operating system? What do you mean that you have multiple scripts running? Commented Aug 12, 2013 at 5:39
  • Hi Joespina and Sverri, i have updated the question. Commented Aug 12, 2013 at 6:34

1 Answer 1

1

Well, identify the script and then kill it, addressing it by its process id (kill <pid>).

Have a look through the process list, if you canned the interpreter with the script as an argument then it will show up there: ps aux|grep php. Or, if you use shebangs inside the script (so that you can call it without explicitly starting the php interpreter), then search for it by the script name...

You might have to switch your effective user id if that php script was not started by you.

Sign up to request clarification or add additional context in comments.

7 Comments

Thank you very much. When i run the command ps aux|grep php, there is a list of php running script (with the file name). However some running php scripts (include the one that i want to stop) are not shown. I'm sure these script is running because these scripts insert rows into my database and i see the table is continuously being inserted
Oh, i have realized that all script running by open the php files in browser do not show up. All child script (executed via exec) were shown. How do i get the pid for the script that i run in my browser?
That is something different: those scripts are not started as a separate process, unless you use the old fashioned cgi method to run php scripts. Thus you cannot address/kill them on process level. Instead the php interpreter is started a bunch of times by the web server (http server) and upon request feeds the scripts into those interpreter instances currently idle. Check the excellent apache documentation for details. There is not easy way to manipulate that... You would have to implement some control mechanism inside those scripts to be able to control them at runtime...
Thank you so much for your very detail explanation. Could you suggest the keywords for these control mechanisms so that i can search for more information?
What I meant is: if you have this situation on a regular base (not only now), then you might want to change your php script to listen to some external event and react to it, for example by terminating themselves. Easiest would be to have some check inside the main loop (sounds like your scripts process some list, so interate through some sort of loop). The check could look if its own lock file it placed on startup inside the local file system still exists. This way you could terminate a script by removing the lock file from command line. But it is not really a satisfying solution.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.