There's a few different possible approaches:
- After failing to update the first time, fork. Parent exits, child sleeps 5 minutes, tries to post, and loops until successful. Runs the risk of lost updates if computer is shutdown before successful.
- Have a system daemon that reads from a spooler file. The user client only appends updates to the Twitter spool and alerts the daemon of a new update.
- After failing, simply caches the update and exits. Next time, on startup, check the cache file for updates, and attempt to post them. Does mean that if the client isn't used for a prolonged time, the update won't be posted until then.