I have a Script called "test.sh" in my Home Directory
I want to be able to run it in crontab.
I have added
* * * * * /home/tom/test.sh
to the crontab however it doesn't seem to be excecuting.
I can excecute ./test.sh fine normally in a Terminal Window.
Edit:
This is the content of my script "test.sh"
#!/bin/sh
gnome-terminal -- sh -c 'cd Server && ./start.sh'
It creates a new terminal window, changes directory to Server and runs another executable script.
I do not know if this has something to do with the script not working in Cron.
The error I get in /var/log/syslog is:
CRON[18694]: (tom) CMD (sh /home/tom/test.sh)
CRON[18693]: (CRON) info (No MTA installed, discarding output)
/home/tom/test.sh
. Also results fromjournalctl | grep test.sh
might provide clues to you. – WinEunuuchs2Unix Apr 18 '20 at 16:14cron
was never really intended for running desktop applications - if you insist on doing it, see How to start a GUI application from cron? – steeldriver Apr 18 '20 at 22:01* * * * * su tom -c "DISPLAY=:0.0 sh /home/tom/test.sh"
however still doesn't seem to be working @steeldriver – tdubz Apr 19 '20 at 09:00DISPLAY
is not sufficient, they need to make a connection to the desktop session's DBUS. See for example How to use notify-send with crontab?. FWIW I would recommend putting the relevantDISPLAY
andDBUS_SESSION_BUS_ADDRESS
commands inside your test.sh script. – steeldriver Apr 19 '20 at 11:56eval "export $(egrep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -u $LOGNAME gnome-session)/environ)";
to my test.sh. – tdubz Apr 19 '20 at 12:12