Which grants to acknowledge, for papers written over a long period of time? I often write papers (usually with coauthors) over long periods, say 5-10 years. (In mathematics, this is fairly typical.) Over this time period I've enjoyed a number of research grants, most of them fairly small.

How do I know which of them to acknowledge in my papers? A literal reading of the grant funders' rules seems to suggest that I should acknowledge all of them. However, this seems a bit over the top, and nobody seems to do this in practice.
While it might seem over the top, it also seems to be good politics if you want to keep funders happy and the old lucre flowing your way, even if slowly. 

I assume that you are talking about five or so grants, not twenty or more. Try to work up a short paragraph you can include in your work that mentions each agency, at least. If there aren't too many you could probably mention the grants by name instead of just the agencies, especially for the larger ones. 

But the rules were set when you accepted the money. It is best to follow them. 

It might be good, as a matter of practice, to separate out which grant supports which paper, specifically, though it is a bit hard if you haven't made it a regular practice. But you might be able to reconstruct a timeline from the dates grants were effective and the start of any research project, just by looking at the dates of early versions of paper drafts and correspondence with coauthors on the ideas. 

And some of the grant requests likely mentioned specific lines of inquiry that the grant would support. Knowing what you wrote then should help you determine which papers should credit those grants.