Ubuntu – Notify-send doesn’t work from crontab

cronnotify-send

I made a script that should notify me when there's a new chapter of manga that I'm reading.
I used the command notify-send to do this.
The program works when I am trying to run it in terminal.
The notification is showing.
However, when I placed this in my crontab, the notification doesn't show.
I'm pretty sure that the program is running since I made it to create a file for me.
The file was created, but the notification didn't show.

Here's my script

#!/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

And here's what I wrote in my crontab

0,15,30,45 12-23 * * 3   /home/jchester/bin/opreminder.sh

Best Answer

Commands need to reference their location. So notify-send needs to be /usr/bin/notify-send

All commands need to have their full path.

Use the whereis notify-send command to see where your commands "live"

Related Question