Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
cron作业未邮寄urlwatch的输出_Cron - Fatal编程技术网

cron作业未邮寄urlwatch的输出

cron作业未邮寄urlwatch的输出,cron,Cron,我有一个像这样的cron工作: * * * * * urlwatch | mail -s "job changes" pc_xxx@msn.com urlwatch > ~/.urlwatch/output.txt mail -s "output" pc_xxx@msn.com < ~/.urlwatch/output.txt urlwatch > ~/.urlwatch/output.txt | mail -s "output" pc_xxx@msn.com <

我有一个像这样的cron工作:

* * * * * urlwatch | mail -s "job  changes" pc_xxx@msn.com
urlwatch > ~/.urlwatch/output.txt
 mail -s "output" pc_xxx@msn.com < ~/.urlwatch/output.txt
urlwatch > ~/.urlwatch/output.txt | mail -s "output" pc_xxx@msn.com < ~/.urlwatch/output.txt
它按预期每分钟发送一次邮件。但是,当我在本地服务器上更改测试html页面时,它不会通过电子邮件发送差异,只会继续发送一封标题为“作业更改”的空白邮件

将作业粘贴到提示时:

pc@dellbox:/$urlwatch | mail -s "job  changes" pc_xxx@msn.com
并在更改html之前/之后运行,它会按预期在第二封电子邮件中发送差异

(pc是URL.txt的所有者,cronjob由pc通过crontab-e创建)

为什么cron版本不通过电子邮件发送urlwatch输出

这让我快疯了

感谢您的帮助

ps无法将urlwatch创建为新标记-需要1500个代表:(

更新:

如果我将命令拆分为如下两位:

* * * * * urlwatch | mail -s "job  changes" pc_xxx@msn.com
urlwatch > ~/.urlwatch/output.txt
 mail -s "output" pc_xxx@msn.com < ~/.urlwatch/output.txt
urlwatch > ~/.urlwatch/output.txt | mail -s "output" pc_xxx@msn.com < ~/.urlwatch/output.txt
我注意到urlwatch需要2-3秒才能完成,我理解shell命令会等待前面的命令完成(除非您使用&?)。不知道这是否重要


另外,我正在使用sSMTP…

.urlwatch
目录放在
/root/
下,因为程序将在那里查看以存储其数据

调用urlwatch时使用完整路径:

$ which urlwatch
/usr/bin/urlwatch
那么您的cron必须是:

* * * * * /usr/bin/urlwatch | mail -s "job  changes" pc_xxx@msn.com

@askchipbug:您的案例看起来非常具体,但以下是一些可以帮助您解决的问题:

-检查/var/log/mail.err或/var/log/mail.log以查找提示 -crontab用户/权限 -某些服务器剥离内容的原因不充分 -我使用mailx,它对我来说很好,下面是我在crontab-e中的cron工作:

* * * * * urlwatch --urls=/var/www/html/urls.txt --hooks=/home/foo/hooks.py | mailx -v -r "bar@gmail.com" -s "This is the subject line" -S smtp="smtp.gmail.com:587" -S smtp-use-starttls -S smtp-auth=login -S smtp-auth-user="foo2@gmail.com" -S smtp-auth-password="bardaf16charsfoo" -S ssl-verify=ignore receipient@hotmail.com
  • 我在此处找到了Herigloom mailx客户端安装的信息:

希望有帮助。

在linux终端中尝试此操作:
cat somefile.html | mail-s“job changes”pc_xxx@msn.com
ok刚试过-文件作为内容通过电子邮件发送。下一步是什么…不,将文件移动到/root/.urlwatch/urls.txt,我得到:错误:您需要先创建一个urls.txt文件。将其放置在/home/pc/.urlwatch/urls.txt中