I heard the Messenger of Allah ﷺ say, "Every deceased person has their deeds sealed off, except for the one who stands guard in the path of Allah. His reward continues to flow until the Day of Resurrection, and he is protected from the trial of the grave."
سمعت رسول الله ﷺ يقول: كل ميت يختم على عمله إلا المرابط في سبيل الله، فإنه يجري له أجر عمله حتى يبعث، ويؤمن من فتان القبر.
Ahmad (17359) narrated it from Abdullah bin Yazid, who said, Ibn Lahia narrated to us, Mushrih narrated to us, saying, I heard Uqba bin Amir mention something similar.Its chain is hasan because of Ibn Lahia, since the one narrating from him is one of the Abadila, and this has already been discussed in the Book of Funerals, in the chapter on garrison duty in the path of Allah as protection from the punishment of the grave.