Setting Up A Cronjob In Windows Xampp

后端 未结 5 1146
终归单人心
终归单人心 2020-12-04 20:35

Help needed to set up this command in my Xampp windows server

0 * * * *     cd C:/xampp/htdocs/plugins/moviefeed/ && php cron.php

C

5条回答
  •  情话喂你
    2020-12-04 21:04

    I'll add nothing new but just a test case. Using the Task Scheduler GUI would be troublesome/unnecessary for a simple cron job, so this demo uses .bat files. What the demo does is just increment the number in the "counter.txt" by 1 every minute.


    Created a "cron" folder in "htdocs" with these files:

    • counter.txt
    • index.php
    • schtask_add.bat
    • schtask_del.bat
    • schtask_query.bat

    Contents of the files:

    counter.txt

    0
    

    index.php

    schtask_add.bat

    @echo off
    schtasks /Create /TN XAMPP /TR "C:/xampp/php/php-win.exe C:/xampp/htdocs/cron/index.php" /SC MINUTE /MO 1
    pause
    

    schtask_del.bat

    @echo off
    schtasks /Delete /TN XAMPP /F
    pause
    

    schtask_query

    @echo off
    schtasks /Query /TN XAMPP
    pause
    

    Tested with XAMPP 7.1.11 on Windows 10 (64-bit).


    Schtasks.exe | Microsoft Docs

    Schtasks - Scheduled tasks - Windows CMD - SS64.com

    PHP: CLI and CGI - Manual (php.exe vs php-win.exe)

提交回复
热议问题