The Prophet ﷺ said, "The sun and the moon are two of Allah's signs. They do not eclipse for the death of anyone or for his life. So when you see that, remember Allah."
قال النبي ﷺ: إن الشمس والقمر آيتان من آيات الله لا يخسفان لموت أحد ولا لحياته، فإذا رأيتم ذلك فاذكروا الله.
Bukhari narrated it in the Beginning of Creation (3202), and Muslim in the Eclipse (17:907), both through Zayd bin Aslam, from Ata bin Yasar, from Abdullah bin Abbas, who related it. This is the wording of Bukhari, and the wording of Muslim is similar to it but longer.