Hi Guy's I am working with the concept of threading, Here I want to execute a same e php file more than one time simultaneously. Is there is any command to execute php file Thanks in advance Edit/Delete Message
You can use shell functions to execute php. exec("php-cgi /path/to/script.php >/dev/null 2>&1"); exec("php /path/to/script.php >/dev/null 2>&1"); PHP: Or you can use wget and run it in background mode to run simultaneous script. exec("wget -bq -o /dev/null http://www.example.com/script1.php"); exec("wget -bq -o /dev/null http://www.example.com/script2.php"); PHP: Or you can use cURL to execute simultaneously. <?php // create both cURL resources $ch1 = curl_init(); $ch2 = curl_init(); // set URL and other appropriate options curl_setopt($ch1, CURLOPT_URL, "http://www.example.com/script1.php"); curl_setopt($ch1, CURLOPT_HEADER, 0); curl_setopt($ch2, CURLOPT_URL, "http://www.example.com/script2.php"); curl_setopt($ch2, CURLOPT_HEADER, 0); //create the multiple cURL handle $mh = curl_multi_init(); //add the two handles curl_multi_add_handle($mh,$ch1); curl_multi_add_handle($mh,$ch2); $running=null; //execute the handles do { curl_multi_exec($mh,$running); } while ($running > 0); //close the handles curl_multi_remove_handle($ch1); curl_multi_remove_handle($ch2); curl_multi_close($mh); ?> PHP:
Hi Kaizoku Thank's for your post I tried using exec("wget -bq -o /dev/null http://www.example.com/script1.php"); function, along with the file name i passed arguments, but the file is not executed. Please help me to solve this
Okay it looks like you are on shared host or restricted from having extra processes. Try this: exec("wget -q http://www.example.com/script1.php >/dev/null 2>&1"); PHP:
That is strange, the code I gave worked on my server. What OS/Distro are you using? Are you using dedicated or shared hosting? Also turn error_reporting to E_ALL so you will see errors and debug.
Get wget for win32 here: http://www.christopherlewis.com/WGet/WGetFiles.htm or here: http://xoomer.alice.it/hherold/ Version 1.10.2 is on both sites, though the first looks like it was updated recently. Make sure to put it somewhere in your path or call it explicitly.
Because windows can't execute by just calling wget. It doesn't have the feature like /usr/bin in linux I think. You have to execute wget using the absolute path. exec("C:/path/to/wget.exe -q http://www.example.com/script1.php"); PHP:
I don't know anything about that, could test it though. If i wanted multi process headaches, I'd just use perl. Thought if he used wget it would have to be somewhere in the webserver path.
Hi Kaizoku I have uploaded my files into server and tried to execute with both exec() commands The file crawl.php is not executed, but when i execute the file crawl.php separately then it is executed. Our's is LINUX Shared hosting Please help me solve this issue
In am writing coding for my project in my windows machine and after completing i want to upload into our site, which is linux shared hosting site. Now it is working in windows with this function But when i upload and call the file with this either of the function
Hi Kaizoku I got the result as Array ( [0] => wget: /usr/bin/wget /usr/share/man/man1/wget.1.gz ) Whether i have to provide this path in exec()
I think your shared hosts restricts you to extra processes. So try this exec("wget -q http://mycollege.in/crawl.php"); exec("/usr/bin/wget -q http://mycollege.in/crawl.php"); If all fails, the admin probably restricts the usage of wget for normal users.
Hi Also I want to pass the arguments along with the file inside exec() function. I tried like this in windows exec("C:/path/wget.exe -q http://localhost/sitemapprototype/crawl.php?thread=$tnames[0]&url=$url[0]"); The arguments are not passed
You need to wrap it around apostrophes. Arrays need to be wrapped around curly braces as well. exec("C:/path/wget.exe -q 'http://localhost/sitemapprototype/crawl.php?thread={$tnames[0]}&url={$url[0]}'"); PHP: