如何使用crontab的notify-send?
我真的阅读了很多教程,但是crontab没有启动notify send。
我尝试过的:
-
etc/crontab
最后添加:
15 * * * * notify-send 'crontab' 'test'
-
使用crontab接口:
crontab -e
最后添加:
15 * * * * notify-send 'crontab' 'test'
正如@Lnux所建议的那样:
创建.sh,例如test.sh
:
#!/bin/sh eval "export $(egrep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -u $LOGNAME gnome-session)/environ)"; #Code: DISPLAY=:0 notify-send "Test"
然后设置crontab:
crontab -e
在底部,添加:
* * * * * /home/myUser/test.sh
Obs。:您可以将.sh文件放在其他位置,不要忘记允许执行它。
Crontab在后台运行,没有指定的图形输出,它将不显示任何内容。 所以你应该spicify,你想使用哪个输出。 要实现这一点,请在命令之前export DISPLAY=:0 &&
,例如
15 * * * * export DISPLAY=:0 && notify-send 'I am alive!'