linux - 使用 WGET 运行 cronjob PHP 禁用通知电子邮件

标签 linux cron

我使用 godaddy 作为虚拟主机,我喜欢禁用在 cronjob 完成后发送的电子邮件通知。对我来说幸运的是,他们没有帮助,但 cronjob 区域说:

You can have cron send an email every time it runs a command. If you do not want an email to be sent for an individual cron job you can redirect the command’s output to /dev/null like this: mycommand >/dev/null 2>&1

我尝试了几种变体,但似乎没有什么可以解决的。

我的命令:

wget http://example.com/wp-admin/tools.php?page=post-by-email&tab=log&check_mail=1

非常感谢任何建议。

最佳答案

正如 cronjob 区域所说,您需要将命令的输出重定向到 /dev/null

您的命令应如下所示:

wget -O /dev/null -o /dev/null "http://example.com/wp-admin/wp-mail.php" &> /dev/null
  • -O 选项确保将获取的内容发送到 /dev/null

如果您希望将获取的内容下载到服务器文件系统中,您可以使用此选项指定所需文件的路径。

  • -o 选项记录到 /dev/null 而不是 stderr

  • &>/dev/null 是将标准输出输出重定向到 /dev/null 的另一种方式。

注意事项

有关 wget 的更多信息,请查看 ma​​n 页面:您可以在控制台上键入 man wget,或使用在线手册页: http://man.he.net/?topic=wget&section=all

-O-o 都指向 /dev/null 时,输出重定向 ( &> ... ) 不应该需要。

如果不需要下载内容,只需要服务器处理请求,可以简单地使用--spider参数

关于linux - 使用 WGET 运行 cronjob PHP 禁用通知电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27759361/

相关文章:

node.js - 为什么 cron 不执行我的 node.js 脚本?

linux - 如何在没有root权限的情况下在linux上安装软件

linux - 如何在 ubuntu 16.04 中安装 laravel 5.6?

python - 将原始 OpenCV 图像通过管道传输到 FFmpeg

linux - 使用 Jenkins 在 git 中处理文件权限的最佳实践

javascript - CRONTAB 执行 Python,使用 puppeteer 执行 Node 来进行网页抓取不起作用

c++ - 类内信号处理

python - 每天下午 5 点(东部标准时间)运行 cron 脚本

linux - 如何使用脚本在 crontab 中添加新任务

python - 在 Django 中如何安排每日报告以电子邮件形式发送