Jump to content

Remote Starting A PHP File


Kooleo956

Recommended Posts

I have been to several forums about this problem and most of them say to use cron jobs, but I find it annoying to go through cron jobs every time I want this script to start up. Each file has an infinite while loop, and I want the server to execute each file. I do not want to have to force a person to leave the file open to keep the script running and I do not want to go through cron jobs. I just want a PHP page where it creates a ghost user that is run by the server and that ghost user executes these PHP files. I tried something like this:

 

<?php

system("php /home/user/bot/bot.php");

system("php /home/user/bot/message.php");

sleep(10);

system("php /home/user/bot/logs.php");

?>

 

, but it did not work. Could someone please help me, and thank you for reading this if you cannot.

Link to comment
Share on other sites

Most likely php isn't in your path. You will need to use the full path to the executable. eg;

 

system("/usr/bin/php /home/user/bot/bot.php &");

 

Also, make sure error reporting and display errors are on so we can see what is going on.

 

<?php error_reporting(E_ALL) ; ini_set('display_errors','1'); ?>

Link to comment
Share on other sites

No, it never got to run the infinite loop, otherwise It would of exited out immediately because I set it to exit out immediately.

 

Well, thats no infinant loop then is it? Either way, I would have no idea about how long your script runs.

Link to comment
Share on other sites

Try this...

 

<?php

error_reporting(E_ALL) ; ini_set('display_errors','1');

system("/usr/bin/php /home/user/bot/bot.php &",$return);

if ($return ==0) {
  echo "script executed successfully";
} else {
  echo "execution failed";
}

?>

Link to comment
Share on other sites

it says "script executed successfully", but the script did not seem to execute.

 

I changed the script to execute this:

 

<?php

$lfp = fopen('bot.txt', 'w');

fputs($lfp, "this is data.\n");

fclose($lfp);

?>

 

but when I did that, no bot.txt was formed.

 

Oh, and I found out why the cpanel was running slow. Apparently since the path php did not exist, it just made the server lag REALLY bad. Is there a way to prevent that from happening?

Link to comment
Share on other sites

Apparently since the path php did not exist, it just made the server lag REALLY bad. Is there a way to prevent that from happening?

 

Of course if the path to php doesn't exist your script won't execute.

 

You might want to detail exactly what it is your trying to accomplish, this really isn't going anywhere.

 

Do you have access to the php cli?

Link to comment
Share on other sites

actually the link to the php is /php it was rather basic.

 

I am trying to start a php file having the server run the php file rather than the client.

 

 

if i just do

 

system("/php /home/user/bot/bot.php",$return);

 

it returns as failed, but if I do

 

system("/php /home/user/bot/bot.php &",$return);

 

it returns successful

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.