Php Cron Job on XAMPP Windows

偶尔善良 提交于 2019-12-11 03:43:26

问题


Well I am new to the term CRON. What I know about this, it is a Unix concept to schedule particular operation to be executed after a defined time interval.

I need to run a php file, to update database once every hour. But my confusion is with scheduling the execution. I am using XAMPP for local development test on Windows 7.

What I found:

  • How to run a php file as a cron job in cPanel in Bigrock Shared Hosting service?
  • Setting Up A Cronjob In Windows Xampp
  • How to create cron job using PHP?

In all the above links, they are saying to configure a cron job on linux shell level. So is it, that the cron is on OS level and not on application level program.

If yes, then how can I create a cron in php on a shared hosting.? If I do not have access to the command line, then I cannot create a Cron job for php.?

If no, then how?

In all the above example I found one similar fashion of code:

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

What is this * for?


回答1:


Obviously you set crons at OS level not at Application level. Although, Like on Unix/Linux, You can set CRON at windows platform too by using Task Schedular ( All Programs->Accessories->System Tools -> Task Schedular ). I think you should go for VPN or Dedicated Servers for crons to set as it needs access to system resources privately.

Apart from it, Syntax for Crontab command(unix/linux) goes like this:

1 2 3 4 5 /root/backup.sh
1: Minute (0-59)
2: Hours (0-23)
3: Day (0-31)
4: Month (0-12 [12 == December])
5: Day of the week(0-7 [7 or 0 == sunday])
/path/to/command - Script or command name to schedule


来源:https://stackoverflow.com/questions/25236484/php-cron-job-on-xampp-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!