Vixushr Posted August 10, 2011 Author Share Posted August 10, 2011 Sorry for the double post but i assumed since this thread went the wrong way that start fresh i better idea. Anyway mine problem still stands, for some reason certain tasks dont close as they shud so i am looking for the solution to kill tham by PID... ir do you have any other ideas? Thanx! Quote Link to comment Share on other sites More sharing options...
Morg. Posted August 10, 2011 Share Posted August 10, 2011 Yes, correct the code instead of resorting to mad workarounds (hey this script is doing random stuff, let's make another broken script to kill it erratically...) Quote Link to comment Share on other sites More sharing options...
Vixushr Posted August 10, 2011 Author Share Posted August 10, 2011 Well, problem is that i am not coder but i must somehow fix that... Is i possible to insert: set_time_limit(); in a certain part of the script rather than to be on the beginig of the entire script? Can I that way set different times for each particular task? Quote Link to comment Share on other sites More sharing options...
WebStyles Posted August 10, 2011 Share Posted August 10, 2011 like I said 2 days ago: if you have a cron job that you sometimes do not want to execute, then it's the wrong script for the job. My advice: think things over before trying to put tape over them. If you're not a coder, maybe you should hire one to fix things for you before they get out of hand. Quote Link to comment Share on other sites More sharing options...
Morg. Posted August 10, 2011 Share Posted August 10, 2011 Ow ... err you should ask someone to take a look at the script, forcefully killing scripts from outside with no idea of the current state is definitely a bad idea, might as well not run them at all if that is the case. Otherwise you can surely setup a shell script ran through cron that would use top output and a perl regex to find the process running your script and its running time and then based on that issue a kill PID // still a very bad idea but that should work. Quote Link to comment Share on other sites More sharing options...
Vixushr Posted August 10, 2011 Author Share Posted August 10, 2011 I agree, and if i can't find some easy fix i will hire someone... problem is that i can't hire localy (security and competition wise) and to hire an online professional is what i am now trying to fix... he made a script, it worked ok. but now (since we changed host) it has problems with tasks and i can't find that pro anymore... Quote Link to comment Share on other sites More sharing options...
Morg. Posted August 10, 2011 Share Posted August 10, 2011 Mhh just hire me .. I'm cool Quote Link to comment Share on other sites More sharing options...
WebStyles Posted August 10, 2011 Share Posted August 10, 2011 there's a forum here dedicated to freelancers. Post your ad there and you'll get loads of people willing to do the job. Quote Link to comment Share on other sites More sharing options...
Morg. Posted August 10, 2011 Share Posted August 10, 2011 As the man said .. plus it'll be cheaper than asking someone who knows what they do Quote Link to comment Share on other sites More sharing options...
Vixushr Posted August 10, 2011 Author Share Posted August 10, 2011 Just one question... Is it possible to insert set_time_limit to parts of the script like this, will it work? <?php set_time_limit(0); include('curl.php'); echo "<pre>"; set_time_limit(90); $products = test_getxmlinfo(); //print_r($products); if(empty($_GET['action']) && $argc != 3) die('wrong args'); if($_GET['action']=='price' || ($argv[1] == 'action' && $argv[2]=='price')){ getxml(); updatePrice($products); } if($_GET['action']=='state' || ($argv[1] == 'action' && $argv[2]=='state')){ getxml(); updateState($products); } if($_GET['action']=='xxxx' || ($argv[1] == 'download' && $argv[2]=='xxxx')){ xxxx_download(); } if($_GET['action']=='xxxx' || ($argv[1] == 'download' && $argv[2]=='xxxx')){ xxxx_download(); } if($_GET['action']=='xxxx' || ($argv[1] == 'download' && $argv[2]=='xxxx')){ xxxx_download(); } if($_GET['action']=='xxxx' || ($argv[1] == 'download' && $argv[2]=='xxxx')){ xxxx_download(); } if($_GET['action']=='xxxx' || ($argv[1] == 'download' && $argv[2]=='xxxx')){ xxxx_download(); } if($_GET['action']=='xxxx' || ($argv[1] == 'download' && $argv[2]=='xxxx')){ xxxx_download(); } if($_GET['action']=='xxxx' || ($argv[1] == 'download' && $argv[2]=='xxxx')){ xxxx_download(); } set_time_limit(0); function updatePrice($products) { foreach($products as $key=>$value) { if(updateProductPrice($value)) { echo "<pre>"; print_r($key); echo "success"; echo "<pre>"; } else { echo "<pre>"; print_r($key); echo "not-change"; echo "<pre>"; } } } function updateState($products) { foreach($products as $key =>$value) { //updateProductState($value); $id = $key; $id_supplier = getAllProducts($id); if($id_supplier) { if($id_supplier[0]['id_supplier']==89) { $supplier = "xxxx"; } else if($id_supplier[0]['id_supplier']==3) { $supplier = "xxxx"; } else if($id_supplier[0]['id_supplier']==4) { $supplier = "xxxx"; } else if($id_supplier[0]['id_supplier']==90) { $supplier = "xxxx"; } else if($id_supplier[0]['id_supplier']==91) { $supplier = "xxxx"; } else if($id_supplier[0]['id_supplier']==92) { $supplier = "xxxx"; } else if($id_supplier[0]['id_supplier']==169) { $supplier = "xxxx"; } else if($id_supplier[0]['id_supplier']==167) { $supplier = "xxxx"; } else { $supplier = ""; } if($supplier=="") { echo "<pre>"; print_r($key); echo "not-change"; echo "<pre>"; } else { if(checkQTY($products[$id][$supplier],$supplier,$id)) { echo "<pre>"; print_r($key); echo "success"; echo "<pre>"; } else { //updatePrice($products); if(updateProductPrice($value)) { echo "<pre>"; print_r($key); echo "success"; echo "<pre>"; } else { echo "<pre>"; print_r($key); echo "not-change"; echo "<pre>"; } } } } } } ?> Quote Link to comment Share on other sites More sharing options...
Vixushr Posted August 10, 2011 Author Share Posted August 10, 2011 Anyone? Quote Link to comment Share on other sites More sharing options...
Vixushr Posted August 10, 2011 Author Share Posted August 10, 2011 more help needed... Iw found this script: <?php /** PHP Kill Process Sometimes, it can happen a script keeps running when it shouldn't, and it won't stop after we close the browser, or shutdown the computer. Because it's not always easy to use SSH there's a workaround. @author Jensen Somers < php@jsomers.be> @version 1.0 */ class KillAllProcesses { /** * Construct the class */ function killallprocesses() { $this->listItems(); } /** * List all the items */ function listItems() { /* * PS Unix command to report process status * -x Select processes without controlling ttys * * Output will look like: * 16479 pts/13 S 0:00 -bash * 21944 pts/13 R 0:00 ps x * */ $output = shell_exec('ps x'); $this->output($output); // Put each individual line into an array $array = explode("\n", $output); $this->doKill($array); } /** * Print the process list * @param string $output */ function output($output) { print "<pre>".$output."</pre>"; } /** Kill all the processes It should be possible to filter in this, but I won't do it now. @param array $array */ function doKill($array) { /* Because the first line of our $output will look like PID TTY STAT TIME COMMAND we'll skip this one. */ for ($i = 1; $i < count($array); $i++) { $id = substr($array[$i], 0, strpos($array[$i], ' ?')); shell_exec('kill '.$id); } } } new KillAllProcesses(); ?> It works well and it kills all processes Now mine processes have constant COMMAND and PID is normaly, allways different... question now is can i kill proces by COMMAND instead of PID? tnx. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.