【问题标题】:Running a PHP page every minute with CronJob使用 CronJob 每分钟运行一个 PHP 页面
【发布时间】:2014-11-03 22:43:43
【问题描述】:

我有

wget -O /dev/null http://example.com/job.php 2>/dev/null

但是我不知道它的真正含义是什么?我唯一知道的是它使用名为 wget 的应用程序,其中一个参数是我要运行的页面。其他的,我不知道。 -O /dev/null2>/dev/null?

注意:这是来自在 FreeBSD 上运行的 cPanel。

【问题讨论】:

    标签: cron wget cpanel


    【解决方案1】:

    您的命令 wget 只是向指定的 URL 发送一个 GET 请求。

    2> /dev/null -> 将错误发送到 /dev/null(意味着什么都不发送)。

    因此不会记录错误。

    【讨论】:

      【解决方案2】:

      此命令不会在您的屏幕上显示任何内容,也不会在您的计算机中写入任何文件。

      让我们重点关注每个部分:

      wget -O /dev/null http://example.com/job.php 2>/dev/null
      

      /dev/null 是一个特殊文件,它会丢弃所有写入它的数据,但会报告 写操作成功。 (Wikipedia)

      因此,每当我们写入或重定向到/dev/null 时,数据都不会被保存。

      由于wget -O file代表将网页下载到filewget -O /dev/null只会下载但不会被找到。

      示例

      $ wget www.google.cat **-o test**
      --2013-05-25 16:42:09--  http://www.google.cat/
      Resolving www.google.cat (www.google.cat)... 173.194.78.94, 2a00:1450:400c:c05::5e
      Connecting to www.google.cat (www.google.cat)|173.194.78.94|:80... connected.
      HTTP request sent, awaiting response... 200 OK
      Length: unspecified [text/html]
      Saving to: `index.html'
      
          [ <=> ] 11,086      --.-K/s   in 0.007s
      
      2013-05-25 16:42:09 (1.62 MB/s) - `test' saved [11086]
      
      $ ll
      -rw-rw-r-- 1 me me 11086 May 25 16:42 test
      
      
      $ wget www.google.cat **-O /dev/null**
      --2013-05-25 16:51:39--  http://www.google.cat/
      Resolving www.google.cat (www.google.cat)... 173.194.78.94, 2a00:1450:400c:c06::5e
      Connecting to www.google.cat (www.google.cat)|173.194.78.94|:80... connected.
      HTTP request sent, awaiting response... 200 OK
      Length: unspecified [text/html]
      Saving to: `/dev/null'
      
          [ <=> ] 11,118      --.-K/s   in 0.004s  
      
      2013-05-25 16:51:39 (2.66 MB/s) - `/dev/null' saved [11118]
      
      $ ll
      total 0
      

      关于另一部分:

      2>/dev/null
      

      2 代表标准错误。所以2 &gt; /devnull 重定向wget 执行的可能错误,使它们不会出现在您的屏幕中。


      您可以查看some examples or wget usage

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-08-26
        • 2015-04-25
        • 1970-01-01
        • 2023-03-16
        • 2018-05-28
        • 2014-11-02
        • 1970-01-01
        • 2011-06-21
        相关资源
        最近更新 更多