Jabir bin Abdullah reported,

The Messenger of Allah ﷺ said, "Whoever among you fears that he will not wake up at the end of the night, let him pray witr at the beginning of the night and then sleep. Whoever among you is confident that he will wake up at the end of the night, let him pray witr at the end of the night, for the recitation at the end of the night is witnessed, and that is better."

Ibn Majah 1187

Sahih

حدثنا عبد الله بن سعيد حدثنا ابن أبي غنية حدثنا الأعمش عن أبي سفيان

عن جابر

عن رسول الله ﷺ قال من خاف منكم أن لا يستيقظ من آخر الليل فليوتر من أول الليل ثم ليرقد ومن طمع منكم أن يستيقظ من آخر الليل فليوتر من آخر الليل فإن قراءة آخر الليل محضورة وذلك أفضل

ابن ماجه 1187صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Establishing prayer and the sunnah regarding it
Chapter
Witr at the end of the night
Numbering
Darussalam 1187
Ibn Majah 1187