使用通知发送和cron

使用通知发送和cron,cron,notify,Cron,Notify,我一直在尝试使用cron的notify send。我已经查看了stackoverflow和其他论坛上给出的大量答案。但是我没有看到通知发送弹出窗口出现。我目前正在运行Ubuntu 13.10。我已经能够让它更早地工作(大约3个月前,当我有Ubuntu 11.10时),但我不记得怎么做,也不知道我在这里做错了什么 我当前的crontab如下所示: */1 * * * * export DISPLAY=:0.0 && export XAUTHORITY=/home/harold/.X

我一直在尝试使用cron的
notify send
。我已经查看了stackoverflow和其他论坛上给出的大量答案。但是我没有看到通知发送弹出窗口出现。我目前正在运行Ubuntu 13.10。我已经能够让它更早地工作(大约3个月前,当我有Ubuntu 11.10时),但我不记得怎么做,也不知道我在这里做错了什么

我当前的crontab如下所示:

*/1 * * * * export DISPLAY=:0.0 && export XAUTHORITY=/home/harold/.Xauthority && /usr/bin/notify-send "$(date)"
*/1 * * * * cd /home/harold/bin && ./notify-send-test.sh
#!/bin/bash
#export DISPLAY=:0
#export XAUTHORITY=/home/harold/.Xauthority
/usr/bin/notify-send "$(date)"
echo "trying to notify at $(date)" >> /home/harold/bin/cronlog.txt
我在网上尝试了很多解决方案,包括在
/usr/bin/notify send…
之前使用
sudo-u harold
。我还尝试使用
导出显示=:0
而不是
=:0.0
。弹出窗口仍然没有出现

我还尝试创建一个脚本。运行脚本的cron作业如下所示:

*/1 * * * * export DISPLAY=:0.0 && export XAUTHORITY=/home/harold/.Xauthority && /usr/bin/notify-send "$(date)"
*/1 * * * * cd /home/harold/bin && ./notify-send-test.sh
#!/bin/bash
#export DISPLAY=:0
#export XAUTHORITY=/home/harold/.Xauthority
/usr/bin/notify-send "$(date)"
echo "trying to notify at $(date)" >> /home/harold/bin/cronlog.txt
我的脚本(
notify send test.sh
)如下所示:

*/1 * * * * export DISPLAY=:0.0 && export XAUTHORITY=/home/harold/.Xauthority && /usr/bin/notify-send "$(date)"
*/1 * * * * cd /home/harold/bin && ./notify-send-test.sh
#!/bin/bash
#export DISPLAY=:0
#export XAUTHORITY=/home/harold/.Xauthority
/usr/bin/notify-send "$(date)"
echo "trying to notify at $(date)" >> /home/harold/bin/cronlog.txt
我试过使用注释行而不使用它们。这些组合似乎都不起作用。我还尝试过使用
export DISPLAY=0.0

我每分钟都会在cronlog.txt文件中获得预期的输出。这意味着我的脚本正在执行,但notify send没有执行

我想知道我做错了什么。乐意提供更多有用的信息

第二个问题:
还有一点是关于cron不能使用某些环境变量。我不明白这意味着什么以及它如何影响我使用cron的方式。如果有人能解释一下就好了

不会在cron守护进程中设置DBUS\u SESSION\u BUS\u ADDRESSenv变量。设置此值将解决您的问题。将以下更改添加到.sh文件并从crontab调用它

通知发送测试。sh

Crontab


*/1****/home/harold/bin/notify send test.sh

你做过这个吗?@fraxture,我不得不放弃这项工作一段时间(相当长的一段时间)。我希望有一天能尝试再次尝试,虽然我还不知道什么时候。没有鹦鹉螺?