Cron Job On local Host Windows Xampp php - php

I have been following this tutorial:
Run Cron Job on PHP Script, on localhost in Windows
The first answer is to set up on wamp... Can anyone tell me what the settings should be to run on Xampp, Windows 8.
PS: when I manualy click on "run" in task scheduler... It runs te desired code (Inserting some data into DB) but not happeneing automatically.

Related

Creating A Scheduled Task on PHP Running Under IIS

I'm fairly new to PHP. I need to run a function on my PHP site on a daily basis. I have seen posts on how to do this under Linux, but I'm running the PHP site on Windows Server 2012 under IIS. How can I create a PHP function and then run it at a certain time each day?
You could use Task Scheduler on the server to run a batch file that runs the PHP script via command line at a regular interval, which i hope should solve your problem.
Run Cron Job on PHP Script, on localhost in Windows
Create script.bat file with below Code
"C:\wamp\bin\php\php5.4.12\php.exe" -f "C:\wamp\www\website\my_process.php"
Change wamp path to your iis path
Download & Install Zcron From Below Link
http://www.z-cron.com/download.html
Create New Task select your script.bat file and set timer

How to Apache run Windows console as administrator?

I have a PHP script that runs one command. The command needs to be runned as administrator. If I run Windows console as administrator and execute the command it works perfectly, on the other hand if I run the script from Windows console as administrator using PHP console it works perfectly.
However if I run the PHP script using Apache server on my PC, my page never finish loading and it does not executes the command in rigth way. I have Apache running as a service and I change the user of Apache to administrator.
Do someone sees a problem with the way I´m doing things?

How to execute shell commands on the host machine from code running inside a vm?

I have a php codebase running in a vagrant vm running on a mac (OS X 10.10). I am trying to execute shell commands with exec(). The commands are evidently executed by the vm shell, but I would like the mac's shell to run it. How if possible could I achieve this? I know the other option is to run the php codebase directly onto the mac, but I was wondering.
Additional information somewhat relevant: The php codebase is Laravel 5 and the vm is Homestead. The reasons why I want to do this is to call an apple script from the mac's terminal in order to start a specific software.
Just share/mount a folder between the Host and the VM, and then you could create a cron job on the Host to read and run the commands from the VM.
First you write to a file from the VM any commands you have that need to be ran on the host. Then just create a cron job on the Host (Mac) that runs every few minutes or seconds checking the file to see if there are any new commands to run. The host acts like a listener, checking and waiting to pick up any commands from the VM, to run in the host environment.

Execute powershell script on webserver when page is accessed

I have a windows 7 Pro computer that is running XAMPP (apache, php).
What I need to do is execute a batch or powershell command on this computer (host) when a remote computer accesses a certain webpage on it. is this possible?
Yes, there is a PHP function that will execute shell code.
Have a look in their documentation
Function: exec("command here");

Getting PHP to run apps on Linux Box

At preset we have need to launch apps on a linux box remotely
To do this we have php script that is run at boot via the rc.local file. This php script watches a command file. This has commands written to it.
The php script has trouble running some apps. For instance it can boot X11, but it can't run an app that is meant for X11.
But, if we run the php script from a terminal, them the system works just just fine
Here is the contents of the rc.local file (this fails).
sudo -u jacob /usr/bin/php /home/listener/ListenerThread.php > /var/www/html/out.txt &
The user jacob as sudo root access with no need for passwords
Please help
Most likely if it's an X11 issue the children aren't having DISPLAY set in their environment, but without error messages we can't help you.
One solution I would suggest is to start X11 at boot and put the line that launches your script into your .xinitrc. This way your script will be able to run GUI programs correctly.
If you don't like that solution, then try running your gui apps from within the script like this: env "DISPLAY=:0.0" your_gui_app

Categories