3

In GNU/Linux, how can one start Thunderbird in the background, let it run for a few minutes for emails to be fetched, and close it afterwards?

1

2 Answers 2

3

It appears that thunderbird does not support this functionality, however, there are some discussions here and here that discuss options for doing this with your window manager/desktop environment. Essentially by running it minimized, with no system tray icon, etc.

To make it only run for a few minutes, you could start TB from a script:

#!/bin/bash
/usr/bin/thunderbird &
sleep 300 # 5 minutes
kill $!

Another option would be to use another program to download your mail for you, and have Thunderbird read the mail from your localdisk. OfflineIMAP does a good job if your mail server supports IMAP. Fetchmail is another option that works with POP3, as well.

1
  • I am currently using fetchmail, procmail, and cron. But I was wondering if this could be done, mostly, in one place: Thunderbird. Context switches considered harmful!
    – 0mid
    Jun 18, 2011 at 5:42
1

The solution I've settled for (thanks to Flimzy's answer) is to use the following script, saved in, say, $HOME/thunderbird_cron.sh

#!/bin/bash
/usr/bin/alltray /usr/bin/thunderbird &
sleep 5m
killall thunderbird-bin

together with the following crontab -e entry

0 0 * * * env DISPLAY=:0.0 $HOME/thunderbird_cron.sh

to run Thunderbird for 5 minutes once a day at midnight, to fetch emails, and have it closed afterwards.

  • kill $!, contrary to what's suggested by Danniel Beck, does not work when the script is run by cron as $! does not return the correct process id there.

  • The env DISPLAY=:0.0 portion will tell cron to use the first screen of the current monitor for Thunderbird. It has to be there for a GUI application to be run by cron.

  • alltray is used to run Thunderbird docked to the tray, effectively making the process of opening and closing invisible to the user.

Update: Even if the option "Check for new messages at startup" is selected (under Account Settings/Server Settings) Thunderbird does not start downloading new messages until after a folder of your email account is selected. (The version I've tested is 3.1.10 under Ubuntu 10.04 LTS.) To automate this selection at startup, the add-on Folderpane Tools can be used. (The method discussed at http://kb.mozillazine.org/Show_Inbox_when_starting_Thunderbird does not work.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .