I regularly invoke a particular remote server from a (Linux/bash) command line via tools like cURL or wget. This server requires an authentication token that expires every 10 minutes. I have a program that can generate a new token.
What I would like is an environment variable, $TOKEN, that I can use from the command line, that refreshes itself every 10 minutes, or, better yet, refreshes itself only when requested, and even then only every 10 minutes at most.
I was hoping that there was a way to tie an environment variable's evaluation to an executable, allowing me to do so with a script. Failing that, I was wondering if perhaps there was a way to set up a background process that updated the environment variable every 10 minutes.