I was configuring crontab with user "pi" to execute an sh script every 30 mins.

In terminal:crontab -u pi -eI added this line: */30 * * * * /bin/sh /home/pi/test.sh

And in the script test.sh there three lines:

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?


Apparently, transmission-gtk is some graphical program that you wish to start? In that case, you need to tell cron on which display to start it. Try this in your crontab before your line (assuming you're using display 0):

export DISPLAY=:0

You should also have error messages in your mail (probably /var/mail/username). That would tell us more about the problem.

  • I tried ‘ */30 * * * * export DISPLAY=:0 && /bin/sh /home/pi/test.sh ‘ and it finally worked! Than you! – Alxt Dec 25 '18 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.