在凌晨1点5分浏览网页


Getting a page viewed at 5past 1 in the morning

是否有可能(也许通过使用cron作业)在特定时间查看页面以启用JavaScript脚本运行以执行操作?
此页面使用重定向将数据传递给其他php脚本。

编辑:1:05am

我想你说的是1点05分。

使用.getMinutes().getHours()

var currentDate = new Date();
if(currentDate.getHours() == 5 && currentDate.getMinutes() == 5) {
    // run some code    
}

使用cron,您可以在crontab中添加如下内容:

5 1 * * * wget -q -t 1 -O - http://www.yoursite.com/cronjob.php

这将要求http://www.yoursite.com/cronjob.php每天凌晨1:05。但是,不会运行嵌入在页面中的Javascript。

如果你需要在页面上运行Javascript,你应该看看PhantomJS

可以,您可以设置cron作业在某些预定义的时间访问特定的网页

// cron format
seconds minutes hours days months years

Cron格式可能会根据服务器提供程序而更改(Amazon Web Service不允许秒)

所以每天01:05访问你的页面:

* 1 5 * * *

添加指定要访问的页面(设置将根据服务器提供商的不同而不同)

Cron Job可以用于非常长的脚本执行(因为它使用CLI),只是不通过http直接访问页面,而是将其作为文件访问。例如:var'www'current'myScript.php。它将忽略执行时间限制。