Running a php script with a .bat file

后端 未结 6 1503
隐瞒了意图╮
隐瞒了意图╮ 2021-01-17 20:49

I need to run a php script at midnight every night on my server. On a linux system I\'d set up a cron job, but I\'m stuck with a windows system.

I know I have to set

6条回答
  •  無奈伤痛
    2021-01-17 21:38

    The START command optionally accepts a title for the created window as its first argument; in this case, it thinks that C:\Program Files (x86)\PHP\v5.3\php.exe is the title to display and -f (the second argument) is the executable you want to run.

    You can therefore fix this by providing a placeholder title, e.g.

    start "email reminder task" "C:\Program Files (x86)\PHP\v5.3\php.exe" -f C:\inetpub\wwwroot\sitename\crons\reminder-email.php
    

    Or, preferably, you can ditch the START command altogether (you aren't using any of its unique facilities) and just run PHP directly:

    "C:\Program Files (x86)\PHP\v5.3\php.exe" -f C:\inetpub\wwwroot\sitename\crons\reminder-email.php
    

提交回复
热议问题