Can we run PHP script just like jar's files.I want to execute PHP script in background without open it in browser.Is this thing possible ?
Using Crons we can run. Make a batch file with php commands and run it through task scheduler if you are using windows OS or run it as cron for apache.
Related
I run various PHP scripts from the Windows 10 Task Scheduler, and the command prompt window closes after running them. Is there a way to pass an argument from the task scheduler interface to cmd.exe so the Command Prompt window doesn't close after running a specific PHP script? If so ... How?
Thank you, Your comment led me to this useful bit of php code: exec(`cmd /K`);
I have an IIS server with Php and have been trying to execute scripts using exec() and system() with no luck. When i go to the machine and run it by double clicking it, or by opening command and running the batch file, 4 windows pop open with ffmpeg streams going and dump to folder.
With exec("cmd.exe 'c:\inetpub\wwwroot\estf\batch\srRecord.bat'");
I am getting some of the batch file process working (creates new folder and dumps to file, but i can't see the cmd gui anywhere. And my stop.bat won't taskkill the ffmpeg process.
Is there a way to bring up the cmd GUI on the external device, also a way to run the exec() command and pass on so that other devices or batch files can kill these tasks (i am thinking that because the php is still running it, nothing else has rights to stop it.
Regards,
Mitchell
I want to continuously run a ffmpeg command in php and when this process is running other php methods need to execute in their own process without waiting for the ffmpeg command to complete. How can I do this?
Look into CRON
It lets you schedule tasks you want to run in the background at a specified pattern.
Now I am trying to execute php websocket script as a background. For it, I used below command on the AWS terminal.
php chat-server.php >> log.txt &
But strangely it is terminated without any errors.
My question is two.
Why the php command is terminated on AWS? Is there any limitation to run a php script continually as a background service
How can I run it permanently on AWS? I understand I can use a linux script to run my web-socket server permantely (maybe linux script will be re-lunch my php script when it will be terminated). But I don't know well linux commands. Who can help me?
Thanks for your advice!
First, enable PHP logs to see if there are any errors.
Then, to run it permanently, you can use screen or Tmux. It's simple to use and lets you detach the process and run it in the background. So you are able to logout from your ssh session, and the process is still running.
Please read:
https://wiki.archlinux.org/index.php/tmux
http://linux.die.net/man/1/screen
I need to use an Apache handler to run a PHP script, rather than running it through CLI. I'm using APC user cache, which stores variables using the Apache process. If I run my PHP script through CLI, then it won't have access to the APC variables.
A possible solution is creating a directory restricted to localhost and putting my scripts in there. Then, I can use a browser to run the PHP scripts. However, I'm not too experienced with Linux and I don't know how to implement this. Here's how I need it to work:
One of the cron job fires.
The cron job opens the PHP script using a web browser.
After the PHP script is finished processing, the web browser closes.
I don't know how to close the browser once the task is finished. Also, multiple PHP scripts will be running simultaneously (called by different cron jobs), I'm not sure how this will work. I'm using the Lynx browser on CentOS.
In Debian/Ubuntu I can run a script using lynx, say
/usr/bin/lynx -source 'url'
For eg:
/usr/bin/lynx -source http://google.com
Once execution is completed, the browser quits default.