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
https://forums.phpfreaks.com/topic/113475-remote-starting-a-php-file/
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'); ?>

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?

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?

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.