我编写了一个脚本,当我正在读一本漫画的新章节时,该脚本应该通知我。我使用命令notify-send来做到这一点。当我尝试在终端中运行该程序时,该程序可以工作。通知正在显示。但是,当我将其放在crontab中时,不会显示通知。我非常确定该程序正在运行,因为它是为我创建文件的。文件已创建,但未显示通知。
这是我的剧本
#!/bin/bash
#One Piece Manga reminder
#I created a file named .newop that contains the latest chapter.
let new=$(cat ~/.newop)
wget --read-timeout=30 -t20 -O .opreminder.txt http://www.mangareader.net/103/one-piece.html
if (( $(cat .opreminder.txt | grep "One Piece $new" | wc -l) >=1 ))
then
(( new+=1 ))
echo $new
echo $new > ~/.newop
notify-send "A new chapter of One Piece was released."
else
notify-send "No new chapter for One Piece."
notify-send "The latest chapter is still $new."
fi
exit
这就是我在crontab中写的
0,15,30,45 12-23 * * 3 /home/jchester/bin/opreminder.sh
命令需要引用其位置。所以notify-send
需要/usr/bin/notify-send
所有命令都必须具有其完整路径。
使用whereis notify-send
命令查看您的命令在何处“存活”
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句