erikstokes's answer will only run the command one time with 300s delay every time the user becomes idle:
Emacs becomes idle when it starts waiting for user input, and it remains idle until the user provides some input. If a timer is set for five seconds of idleness, it runs approximately five seconds after Emacs first becomes idle. Even if repeat is non-nil, this timer will not run again as long as Emacs remains idle, because the duration of idleness will continue to increase and will not go down to five seconds again. (source)
To make it automatically update every five minutes (even during idle), we can do something like this (reference: the code in https://www.gnu.org/software/emacs/manual/html_node/elisp/Idle-Timers.html):
(defvar refresh-agenda-time-seconds 300)
(defvar refresh-agenda-timer nil
"Timer for `refresh-agenda-timer-function' to reschedule itself, or nil.")
(defun refresh-agenda-timer-function ()
;; If the user types a command while refresh-agenda-timer
;; is active, the next time this function is called from
;; its main idle timer, deactivate refresh-agenda-timer.
(org-agenda nil "a")
;; Compute an idle time break-length
;; more than the current value.
(time-add (current-idle-time) refresh-agenda-time-seconds)
(run-with-idle-timer refresh-agenda-time-seconds t 'refresh-agenda-timer-function)