Schedule and execute a PHP script automatically

I wrote a PHP script that generates a sql file containing all the tables in my database. I want to do this script daily or every n days. I read about cron, but actually use Windows. How can I automate script execution on the server? Thanks!

+4
source share
6 answers

You will need to add a scheduled task to call the url.

First of all, read here: MS KB is for Windows XP.

Secondly, you need to call the url somehow - I would recommend using something like wget - this way you can call the url and save the output to a file so you can see what debugging output is. You can get wget on this page .

The final step, as Gabriel says, is to write a batch file to tie it all together and then leave.

e: wget is pretty easy to use, but if you have any problems leave a comment and I will help.

ee: thinking about this, you don’t even need a batch file, and it can just call wget directly ..

+4
source

Add a scheduled task to request a URL. either using a batch file or script file (WSH).

http://blog.netnerds.net/2007/01/vbscript-download-and-save-a-binary-file/

this script will allow you to download binary data from a web source. Change it to work for you in a specific case. This vbs file can be run directly or executed from a script. Alternatively, you do not need to save the file using a script, you can simply output the contents (WScript.Echo objXMLHTTP.ResponseBody) and use the CMD out argument for the file:

cscript download.vbs> logfile.log

save this bad boy in a .bat file somewhere useful and call it in the scheduler: http://lifehacker.com/153089/hack-attack-using-windows-scheduled-tasks

+2
source

There is no cron on Windows, but it comes with a command on command . It is not as flexible as cron, but it allows you to schedule arbitrary tasks to be run from the command line.

0
source

Cron is not always available on many hosting accounts.

But try this: http://www.phpjobscheduler.co.uk/ its free, has a useful interface so you can see all scheduled tasks and run on any host that provides php and mysql.

0
source

Yes, you can plan and execute your php script on Windows to run automatically. On linux, for example, os u will have cron, but on Windows you can schedule a task using the task scheduler.

0
source

You can use the ATrigger distribution service . The PHP library is also available for creating scheduled tasks without overhead. Reporting, analytics, error handling and other benefits.

Disclaimer: I was among the Atrigger team. This is a free program and I have no commercial purpose.

0
source

Source: https://habr.com/ru/post/1308744/


All Articles