How long do gas and oil royalties last?

They usually last until the well or field is no longer economically workable. Most royalty arrangements do not have a time limit, but any kind of contract is possible. The royalty rights can be sold and resold endlessly and modified at each step. Sometimes after stopping for awhile, the royalties can resume if the price of oil or gas increases enough to make the operation profitable again or someone figures out a way to economically recover more of the remaining deposit.