473,657 Members | 2,432 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to terminate a script

93 New Member
I've got a script which uses cURL to connect to another website, and it seems to be getting stuck (I can't quite figure out how, but that's besides the point!). The trouble is that when my script runs it redirects you to a "please wait" page, and it then executes by itself. So you can't click 'stop' in your browser to terminate the script. If the script gets a fatal error, then the 'results' page will display an error saying that the script failed. If the script finishes successfully then obviously the 'results' page will have the results on it.

But my script appears to get stuck, and just never produces a results page, and never produces an error. So it must still be executing. The script wouldn't necessarily time out because time spent doing cURL connections doesn't count towards the script's execution time. And despite my cURL settings, cURL doesn't seem to timeout either. So my script is stuck in eternal limbo, which worries me because I've now probably got several scripts all running forever on my webserver! (Deleting the php file doesn't help, because php appears to store it in ram in order to execute it, so it keeps running even after you've deleted it.)

So to get to the point.....

How can I get php to terminate everything its doing (i.e. all scripts that its running) without shutting down the webserver? I can't shut down the web server because it's on a paid hosting thing, and I don't have that kind of access to it (only cpanel).

What are 'cron jobs'? Could I create one that resets php?
Jul 17 '07 #1
9 2606
mwasif
802 Recognized Expert Contributor
Check out this link to know about cronjob.

Set timeouts (CURLOPT_CONNEC TTIMEOUT and CURLOPT_TIMEOUT ) for cURL using curl_setopt.
Jul 17 '07 #2
adamalton
93 New Member
Yeah, I'm already using CURLOPT_TIMEOUT , CURLOPT_CONNECT TIMEOUT , CURLOPT_LOWSPEE DLIMIT, and CURLOPT_LOWSPEE D_TIME. Which is why I can't understand why it's getting stuck.

I'll have a read about cronjobs
Jul 17 '07 #3
Motoma
3,237 Recognized Expert Specialist
But my script appears to get stuck, and just never produces a results page, and never produces an error. So it must still be executing.
Not necessarily. Take a look at the top post in this forum, it will tell you how to ensure that you receive all error messages for properly debugging php scripts.
Jul 17 '07 #4
adamalton
93 New Member
It appears that my scripts are not getting stuck at all! Quite the opposite...they are failing...silen tly!

The curl_multi_sele ct() function causes php to fail, without outputting any error message. I've submitted a bug on the php.net site.
Jul 17 '07 #5
Motoma
3,237 Recognized Expert Specialist
It appears that my scripts are not getting stuck at all! Quite the opposite...they are failing...silen tly!

The curl_multi_sele ct() function causes php to fail, without outputting any error message. I've submitted a bug on the php.net site.
Hrm, could you post a simple test case for us to try out?
Jul 18 '07 #6
adamalton
93 New Member
I'll have more of an investiagtion today, and see if I can post some example code.

The problem is that I'm using the function in a script which is included in another script which is included in another script, and sometimes when the script is included it works and sometimes when it's included it just fails, silently. I can't figure out what makes it fail, but it definitely shouldn't just fail silently.

Here's my bug:
http://bugs.php.net/bug.php?id=4202 0
Jul 18 '07 #7
tscott
22 New Member
Hmm... Code looks really disorganized to me and there aren't as many {} as there should be, a while statement was ended with a ; . Yeah... that code = :S

Needs to be dubugged.

~Tyler
Jul 20 '07 #8
adamalton
93 New Member
Trust me, the code works. And anyway, if it didn't then php would give an error message, not just self destruct! The strange thing is that the problem never occurs on my own server (Mac OSX) but it does on my webhost's, despite them both having the same php version. I'm going to start a new discussion to get some help with disabling the optimizers etc to see if they are causing the problem.
Jul 20 '07 #9
Motoma
3,237 Recognized Expert Specialist
Trust me, the code works. And anyway, if it didn't then php would give an error message, not just self destruct! The strange thing is that the problem never occurs on my own server (Mac OSX) but it does on my webhost's, despite them both having the same php version. I'm going to start a new discussion to get some help with disabling the optimizers etc to see if they are causing the problem.
Any hopes of us getting a simple test case to demonstrate the bug?
Jul 21 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2366
by: yawnmoth | last post by:
i've written a php script to test proxy servers, but when i run it from the command line, it doesn't terminate. i have to hit Ctrl+C to terminate it. so, any ideas as to what i'm doing wrong, and how i could fix it? here's the code: <? $address = 'whatever'; $port = 80; $proxy = fsockopen("tcp://$address", (int) $port, $errno, $errstr, 1)
5
36411
by: Helmut Jarausch | last post by:
Hi, I'm still looking for an elegant and clear means to terminate the main script in Python. Unfortunately, Python doesn't allow a 'return' instruction in the main script. Using sys.exit(0) produces an error message which looks dangerous to an
1
2030
by: kk5151 | last post by:
Hi, Do you know any simple script to terminate the iexplorer.exe. On window, I have to go to Task Manager -> processes -> End process of "IExplorer.exe". Currently I have 30 IE browsers running on the PC, and would like to know any simple script to terminate this process. Thanks,
2
2498
by: cnsabar | last post by:
Hi., I am using the following code to terminate the any process by giving the process name as input... use Win32::Process::List; use Win32::OLE; $Win32::OLE::Warn = 3; $P = Win32::Process::List->new(); print "Enter the process name.exe to terminate: ";
0
1690
by: cnsabar | last post by:
Hi., I need a Perl script to terminate the any running process in server. by specifying computer name and process name.. I have the following code to terminate the any process by specifying the process name in the local system... use Win32::Process::List; use Win32::OLE;
1
2451
by: thunder54007 | last post by:
hi, here is my script: import win32con import time import wmi c = wmi.WMI() for process in c.Win32_Process(name = "notepad.exe"): print process.ProcessId, process.Name process.Terminate ()
3
3857
by: Gros Bedo | last post by:
Hello :-) I have a question about Python and Linux shell. I have a python program which is permanently resident in the end-user system. I'm currently producing a RPM package, and it works nicely. The problem is that when I uninstall it, my program keeps running in the background, even if the files are deleted. I know I can terminate python shell directly, but this is not a good ideabecause the end-user may be working with another important...
1
2983
by: Gros Bedo | last post by:
Yes I've seen that each python script calls its own instance of Python. Buthow to know which is the good one in bash ? Is there a command that gets the parameters of process, so I could use grep to select the one containing the name of my script ? _________________________________________________________________ Votre contact a choisi Hotmail, l'e-mail nouvelle génération. Créezun compte. http://www.windowslive.fr/hotmail/default.asp
0
2008
by: norseman | last post by:
Gros Bedo wrote: ============================== Yes. man ps explains try ps -AFL | grep then kill -9 found (check it more than twice) 1) If your script is known to hang use what another wrote: py s.py tokens & capture=$! (get the PID ready)
0
8395
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8826
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6166
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4306
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.