Yogesh Asthana
Yogesh Asthana

Reputation: 99

How to run a php script through batch file for windows 7?

I have 2 php files. One which stores various xml files in a database and other php files takes those xml files as input, parse them and produces a another table having various information about the xml files.

I want this work to be scheduled for everynight. I want to do this via batch files but I have no idea how to use .bat files, and how to incoorporate the php script in it.

Need help/guidance.

Thanks. Yogesh

Upvotes: 0

Views: 785

Answers (2)

ElSinus
ElSinus

Reputation: 106

  1. create start.sh add this code:
    #!/bin/bash
    php /path/to/folder/script.php
  2. chmod 644 script.php

OR

  1. create start.sh add this code:
    #!/bin/bash
    /path/to/folder/script.php
  2. chmod 755 script.php
  3. the first line of your script.php has to be:
    #!/usr/bin/php

Upvotes: 0

Al.
Al.

Reputation: 330

I assume you are doing this on a windows machine as you mention a .bat file

PHP can be executed from a command line e.g. a dos shell

http://www.php.net/manual/en/features.commandline.introduction.php

Once you get it working manually just put what you are typing in a text file. (.bat)

You can execute the .bat file (a program file to windows) when you want using a scheduler, e.g. http://windows.microsoft.com/en-GB/windows7/schedule-a-task

Upvotes: 3

Related Questions