I am trying to run a simple script that checks the battery percentage and shows it through a notification (notify-send).
The script runs correctly if ran from terminal manually: ~/path-to-script/my_script.sh or sh ~/path-to-script/my_script.sh or even bash ~/path-to-my-script/my_script.sh.
Where correctly means that the notification is shown.
However when trying to run it through cron no notification appears.
This is what crontab -e looks like:
*/1 * * * * /usr/bin/sh ~/path-to-my-script/my_script.sh
I have, also, set some environment variables in crontab with sudo vim /etc/crontab:
SHELL=/usr/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
And this is the log from sudo service cron status:
gen 28 17:35:01 my_user CRON[7863]: pam_unix(cron:session): session opened for user my_user(uid=1001) by (uid=0)
gen 28 17:35:01 my_user CRON[7864]: (my_user) CMD (/usr/bin/sh ~/path-to-my-script/my_script.sh)
gen 28 17:35:01 my_user CRON[7863]: (CRON) info (No MTA installed, discarding output)
gen 28 17:35:01 my_user CRON[7863]: pam_unix(cron:session): session closed for user my_user
I am running on Ubuntu 22.04 using i3 as window manager. What could be the cause of this issue?
Please ask if more info is needed.