1 hour at 170 degrees will not only kill the bugs, but it will also help dry the grain/beans/rice which helps them not go bad. Yep, it will form a nice vacuum - but be sure to simmer the lids in hot water for about 10 minutes before putting them on - this softens the rubber gasket and they seal better.
Actually, I do this process by using my previously used lids. Wash them well and use them for grains - Even if one does not seal perfectly, it is not the catastrophe that wet vegetables would be.
Speaking of re-using lids, I also do another little thing - when I am doing a pressure canner batch and don’t have enough to fill it,(my canner holds 19 pint jars) I put water in jars and put the reused lids on them - When it comes out, I have sterilized vacuum packed water - AND I don’t have to scrub the inside of the jars when I go to can something like I would if they were empty.
I like to keep my jars full - ‘An empty jar is saving nothing!’ quoteth Me.
Freezing grain for at least 24 hours will also kill those pesties...48+ hours is even better. Problem is until I purge my freezer in the early summer (I take out all remaining meat and vegetables that would freezer burn and can them while they are still tasting good. Then they are good for years and years.) I usually don’t have room for the grains.