Search code examples
phpcygwincroncron-task

Running a PHP Script with Cron From Cygwin


I want to push my cron.txt to crontab using something like:

crontab cron.txt

The contents of my cron.txt file are:

# Format : minute | hour | day-of-month | month | day-of-week | path-to-script

0 1600 * * 4 C:/path/to/myscript.php

I am getting the error:

"cron.txt":4: bad hour

How can I run the script properly? Is all that is needed the time and the path to php file?

Thanks.


Solution

  • You seem to have fixed the invalid hour issue, now if your php script is accessible via the web, why don't you use a curl request as your command?

    0 16 * * 4 curl --request GET 'http://www.yoursite.com/path/to/myscript.php'
    

    Obviously you'd need to secure it, probably with a custom get key or even in .htaccess, only allowing server access.