King David participated in the sacrifice of seven men at the beginning of a barley harvest with an eye towards ending famine in the land.
There was famine in the kingdom of David for three years. When David asked God what he could do about it. God explained that it was because of bloodguilt on Saul because he put the Gibeonites to death.
1Now there was a famine in the days of David for three years, year after year; and David sought the face of the LORD. And the LORD said,"There is bloodguilt on Saul and on his house, because he put the Gibeonites to death." (2 Sam. 21:1)
So David called for the Gibeonites and wanted to know what he could do to expiate for what Saul did.
2So the king called the Gibeonites. Now the Gibeonites were not of the people of Israel, but of the remnant of the Amorites; although the people of Israel had sworn to spare them, Saul had sought to slay them in his zeal for the people of Israel and Judah.
3And David said to the Gibeonites, "What shall I do for you? And how shall I make expiation, that you may bless the heritage of the LORD?" (2 Sam. 21:2-3)
The Gibeonites replied that it was not a matter of money. What they wanted was seven of Saul's sons so they may hang them. David agreed.
4The Gibeonites said to him, "It is not a matter of silver or gold between us and Saul or his house; neither is it for us to put any man to death in Israel." And he said, "What do you say that I shall do for you?"
5They said to the king, "The man who consumed us and planned to destroy us, so that we should have no place in all the territory of Israel,
6let seven of his sons be given to us, so that we may hang them up before the LORD at Gibeon on the mountain of the LORD." And the king said, "I will give them." (2 Sam. 21:4-6)
David picked two of Saul's sons and five of his grandsons. They were hanged on the mountain before God, at the beginning of the barley harvest.
7But the king spared Mephibosheth, the son of Saul's son Jonathan, because of the oath of the LORD which was between them, between David and Jonathan the son of Saul.
8The king took the two sons of Rizpah the daughter of Aiah, whom she bore to Saul, Armoni and Mephibosheth; and the five sons of Merab the daughter of Saul, whom she bore to Adri-el the son of Barzillai the Meholathite;
9and he gave them into the hands of the Gibeonites, and they hanged them on the mountain before the LORD, and the seven of them perished together. They were put to death in the first days of harvest, at the beginning of barley harvest. (2 Sam. 21:7-9)