Moh*_*ows 5 php cron curl wget
我正在尝试创建一个 cronjob,但我不知道这些行之间有什么区别,也不知道我应该使用哪一行来使 Cronjob 正常工作。
0 0 * * * /usr/bin/php5.5 /website/cron.php
0 0 * * * /usr/bin/curl /website/cron.php
0 0 * * * /usr/bin/wget /website/cron.php
Run Code Online (Sandbox Code Playgroud)
现在我需要知道哪一个有效,我确信我的服务器已使用命令行安装了 CURL 和 WGET:
whereis wget
whereis curl
Run Code Online (Sandbox Code Playgroud)
但是当我尝试创建一个简单的 php 文件来向我发送电子邮件时,只有这段代码对我有用:
0 0 * * * /usr/bin/php5.5 /website/cron.php
Run Code Online (Sandbox Code Playgroud)
那么该怎么办?
小智 5
卷曲
\n\ncurl 是一种使用受支持的协议之一从服务器传输数据或向服务器传输数据的工具
\n\n语法是
\n\ncurl [oprions] URL\nRun Code Online (Sandbox Code Playgroud)\n\nURL 语法与协议相关。您可以在 RFC 3986 中找到详细的说明\xe2\x80\x90\n。
\n\nwget 的情况类似
\n\nwget [options] URL\nRun Code Online (Sandbox Code Playgroud)\n\n两者都会通过 HTTP 向 weserver 的 php 模块提交请求,而该模块又仅调用 php 编译器。为了让它们在 cron 中使用,cron.php 必须位于可以通过 HTTP 请求的位置
\n\n喜欢
\n\n0 0 * * * /usr/bin/curl http://web-url/cron.php\n0 0 * * * /usr/bin/wget http://web-url/cron.php\nRun Code Online (Sandbox Code Playgroud)\n\n尽管
\n\n0 0 * * * /usr/bin/php5.5 /website/cron.php\nRun Code Online (Sandbox Code Playgroud)\n\n可以简单地用于运行服务器上本地可用的 php 脚本
\n