I am using Linux Mint 17
.
I want to be informed every 50 min, at every hour for small break.
Here is cron job:
nazar@desktop ~ $ crontab -l
DISPLAY=:0.0
XAUTHORITY=/home/matrix/.Xauthority
00 13 * * * /home/nazar/Documents/scripts/lunch_break_job.sh # JOB_ID_2
50 * * * * /home/nazar/Documents/scripts/pc_break.sh # JOB_ID_1
- /home/nazar/Documents/scripts/cron_job_test.sh # JOB_ID
Here is script for /home/nazar/Documents/scripts/cron_job_test.sh
:
#!/bin/bash
export DISPLAY=0.0
export XAUTHORITY=/home/matrix/.Xauthority
if [ -r "$HOME/.dbus/Xdbus" ]; then
. "$HOME/.dbus/Xdbus"
fi
/usr/bin/notify-send -i "hello"
This snippet of function:
if [ -r "$HOME/.dbus/Xdbus" ]; then
. "$HOME/.dbus/Xdbus"
fi
Checks DBUS_SESSION_BUS_ADDRESS
and uses it.
According to this answer I executed script, and now my Dbus
is saved to $HOME/.dbus/Xdbus
:
nazar@desktop ~ $ cat $HOME/.dbus/Xdbus
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-flm7sXd0I4,guid=df48c9c8d751d2785c5b31875661ebae
export DBUS_SESSION_BUS_ADDRESS
All should work. I couldn't find what is missed. Because notification doesn't work now.
From terminal it works fine:
How to solve this issue?
SOLUTION:
Now my crontab
looks as follows:
DISPLAY=":0.0"
XAUTHORITY="/home/nazar/.Xauthority"
XDG_RUNTIME_DIR="/run/user/1000"
00 13 * * * /home/nazar/Documents/scripts/lunch_break_job.sh # JOB_ID_2
50 * * * * /home/nazar/Documents/scripts/pc_break.sh # JOB_ID_1
# * * * * * /home/nazar/Documents/scripts/cron_job_test.sh # JOB_ID
and cron_job_test.sh
looks now:
#!/bin/bash
/usr/bin/notify-send -i /home/nazar/Pictures/icons/Mail.png "hello" "It is just cron test message"
pc_break.sh
:
#!/bin/bash
/usr/bin/notify-send -i /home/nazar/Pictures/icons/download_manager.png "Break:" "Make a break for 10 min"
lunch_break_job.sh
:
#!/bin/bash
/usr/bin/notify-send -i /home/nazar/Pictures/icons/Apple.png "Lunch: " "Please, take a lunch!"
/home/nazar/Documents/scripts/pc_break.sh
script. Maybe there is an error in there ? – lese Dec 07 '15 at 09:32nazar
?50 * * * * nazar /home/nazar/Documents/scripts/pc_break.sh # JOB_ID_1
– syss Dec 07 '15 at 09:33pc_break
job and script are correct. And this jobcron_job_test.sh
is just test to verify if cron works, in general. – catch23 Dec 07 '15 at 09:36