I was configuring crontab with user "pi" to execute an sh script every 30 mins.
In terminal:crontab -u pi -e
I added this line: */30 * * * * /bin/sh /home/pi/test.sh
And in the script test.sh there three lines:
#!/bin/sh
/usr/bin/transmission-gtk
echo "done" > /home/pi/startup/result.txt
As a result, every 30 minutes the result.txt updated, anyway the transmission-gtk never shows up. Namely, only 1 (of 2) commands in the test.sh worked.
But when I manually execute the /home/pi/test.sh in terminal, everything works fine. The test.txt updated and the transmission-gtk shows up.
I know that everything in crontab should be written with absolute-path and I'm pretty sure that the transmission-gtk is in /usr/bin. And of course, from the above we know the user "pi" has the permission to execute both test.sh and transmission-gtk.
Can anybody tell why is this happening?