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.
我是CRON这个词的新成员。我所知道的是,这是一个Unix概念,它将特定的操作安排在定义的时间间隔之后执行。
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.
我需要运行一个php文件,每小时更新一次数据库。但我的困惑是如何安排执行。我正在使用XAMPP进行Windows 7的本地开发测试。
What I found:
我发现:
- How to run a php file as a cron job in cPanel in Bigrock Shared Hosting service?
- 如何在Bigrock共享托管服务的cPanel中作为cron作业运行php文件?
- Setting Up A Cronjob In Windows Xampp
- 在Windows Xampp中设置Cronjob
- How to create cron job using PHP?
- 如何使用PHP创建cron作业?
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.
在上面的所有链接中,他们说要在linux shell级别上配置cron作业。cron是在OS级别上,而不是在应用程序级别上。
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.?
如果是,那么如何在共享主机上创建php的cron。如果我不能访问命令行,那么我就不能为php创建Cron作业。
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 个解决方案
#1
2
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.
显然,您在OS级别设置crons,而不是在应用程序级别设置crons。尽管,像在Unix/Linux上一样,您也可以在windows平台上设置CRON,也可以使用Task Schedular(所有程序->附件->系统工具->任务Schedular)。我认为您应该选择VPN或者crons专用服务器来设置,因为它需要私下访问系统资源。
Apart from it, Syntax for Crontab command
(unix/linux) goes like this:
除此之外,Crontab命令(unix/linux)的语法如下:
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
#1
2
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.
显然,您在OS级别设置crons,而不是在应用程序级别设置crons。尽管,像在Unix/Linux上一样,您也可以在windows平台上设置CRON,也可以使用Task Schedular(所有程序->附件->系统工具->任务Schedular)。我认为您应该选择VPN或者crons专用服务器来设置,因为它需要私下访问系统资源。
Apart from it, Syntax for Crontab command
(unix/linux) goes like this:
除此之外,Crontab命令(unix/linux)的语法如下:
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