It depends upon the grains. Something like wheat can get rancid unless stored in freezer.
If they are de-germinated, (endosperm removed) that’s different.
Rice and lentils and such can be stored for a really long time as long as there’s no way for pesky bugs to get in. That’s the important part.
Brown rice is the exception. About six months before spoilage and is best kept in fridge or freezer.
The basic rule of thumb is that whole grain products are much more susceptible to degradation.
The more processed, the longer it will last. Parcooked rice (like Uncle Bens) will last practically forever. Not much nutrient value, but long shelf life.
This is also why Twinkies and such survive forever :)