相关疑难解决方法(0)

通知发送在 crontab 中不起作用

我制作了一个脚本,当我正在阅读漫画的新章节时,它会通知我。我使用命令 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 …
Run Code Online (Sandbox Code Playgroud)

cron notify-send

58
推荐指数
6
解决办法
4万
查看次数

标签 统计

cron ×1

notify-send ×1