The Messenger of Allah ﷺ said, "The sun and the moon are two of the signs of Allah the Exalted. They do not eclipse for anyone's death or life, but Allah uses them to instill fear in His servants."
أخبرنا قتيبة قال حدثنا حماد عن يونس عن الحسن
قال رسول الله ﷺ إن الشمس والقمر آيتان من آيات الله تعالى لا ينكسفان لموت أحد ولا لحياته ولكن الله عز وجل يخوف بهما عباده
Bukhari narrated it in the Book of the Eclipse, in the chapter titled "The words of the Prophet ﷺ, 'Allah frightens His servants with the eclipse,'" hadith no. 1048, from Qutayba, with the same wording. It also appears in Kubra, hadith no. 1840.