The Buddha shares a powerful verse on what leads one to have had a single auspicious night.
Bhaddekaratta sutta - A Single Auspicious Night
Thus have I heard — At one time, the Blessed One was dwelling in Sāvatthi, in Jeta's Grove, in Anāthapiṇḍika's park. There the Blessed One addressed the bhikkhus, saying: "Bhikkhus."
"Venerable Sir," those bhikkhus replied to the Blessed One. The Blessed One said this:
"Bhikkhus, I will teach you the summary and analysis of 'One who has had a single auspicious night.' Listen to it and pay close attention, I will speak."
"Yes, venerable sir," those bhikkhus replied to the Blessed One. The Blessed One said this:
Verse
"Let not a person revive the past, nor place hope upon the future; For what is past is left behind, and the future is yet unreached.
With insight, see the present state, as it arises, clear and firm; Unshaken, untroubled, that wise one should develop this mind.
Today, the effort must be made, who knows if death will come tomorrow? For there is no bargaining with death, the great army that spares none.
But one who dwells with continuous effort, diligent, both day and night; It is they, the Peaceful Sage has said, who has had a single auspicious night.
Past
And how, bhikkhus, does one revive the past? One thinks, 'I was of such form in the past,' and thus finds delight there. One thinks, 'I had such feeling in the past,' and thus finds delight there. One thinks, 'I had such perception in the past,' and thus finds delight there. One thinks, 'I had such volitional formations in the past,' and thus finds delight there. One thinks, 'I had such consciousness in the past,' and thus finds delight there. This is how one revives the past.
And how, bhikkhus, does one not revive the past? One thinks, 'I was of such form in the past,' and does not find delight there. One thinks, 'I had such feeling in the past,' and does not find delight there. One thinks, 'I had such perception in the past,' and does not find delight there. One thinks, 'I had such volitional formations in the past,' and does not find delight there. One thinks, 'I had such consciousness in the past,' and does not find delight there. This is how one does not revive the past.
Future
And how, bhikkhus, does one place hope upon the future? One thinks, 'I may have such form in the future,' and thus finds delight there. One thinks, 'I may have such feeling in the future,' and thus finds delight there. One thinks, 'I may have such perception in the future,' and thus finds delight there. One thinks, 'I may have such volitional formations in the future,' and thus finds delight there. One thinks, 'I may have such consciousness in the future,' and thus finds delight there. This is how one places hope upon the future.
And how, bhikkhus, does one not place hope upon the future? One thinks, 'I may have such form in the future,' but does not find delight there. One thinks, 'I may have such feeling in the future,' but does not find delight there. One thinks, 'I may have such perception in the future,' but does not find delight there. One thinks, 'I may have such volitional formations in the future,' but does not find delight there. One thinks, 'I may have such consciousness in the future,' but does not find delight there. This is how one does not place hope upon the future.
Presently Arisen Phenomena
And how, bhikkhus, is one shaken up by presently arisen phenomena? Here, bhikkhus, an unlearned ordinary person who has not seen the noble ones, is unskilled in the noble Dhamma, undisciplined in the noble Dhamma, who has not seen the true persons, is unskilled in the true Dhamma, undisciplined in the true Dhamma, perceives form as self, or self as possessing form, or form as in self, or self as in form; perceives feeling as self, or self as possessing feeling, or feeling as in self, or self as in feeling; perceives perception as self, or self as possessing perception, or perception as in self, or self as in perception; perceives volitional formations as self, or self as possessing volitional formations, or volitional formations as in self, or self as in volitional formations; perceives consciousness as self, or self as possessing consciousness, or consciousness as in self, or self as in consciousness. In this way, bhikkhus, one is shaken up by presently arisen phenomena.
And how, bhikkhus, does one remain unshaken by presently arisen phenomena? Here, bhikkhus, a learned disciple of the noble ones who has seen the noble ones, is skilled in the noble Dhamma, well-disciplined in the noble Dhamma, who has seen the true persons, is skilled in the true Dhamma, well-disciplined in the true Dhamma, does not perceive form as self, nor self as possessing form, nor form as in self, nor self as in form; does not perceive feeling as self, nor self as possessing feeling, nor feeling as in self, nor self as in feeling; does not perceive perception as self, nor self as possessing perception, nor perception as in self, nor self as in perception; does not perceive volitional formations as self, nor self as possessing volitional formations, nor volitional formations as in self, nor self as in volitional formations; does not perceive consciousness as self, nor self as possessing consciousness, nor consciousness as in self, nor self as in consciousness. In this way, bhikkhus, one remains unshaken by presently arisen phenomena."
"Let not a person revive the past, nor place hope upon the future; For what is past is left behind, and the future is yet unreached.
With insight, see the present state, as it arises, clear and firm; Unshaken, untroubled, that wise one should develop this mind.
Today, the effort must be made, who knows if death will come tomorrow? For there is no bargaining with death, the great army that spares none.
But one who dwells with continuous effort, diligent, both day and night; It is they, the Peaceful Sage has said, who has had a single auspicious night. [Repeated]
So it was with reference to this that it was said: 'Bhikkhus, I will teach you the summary and analysis of 'One who has had a single auspicious night.'"
The Blessed One said this. The bhikkhus were satisfied and rejoiced in the Blessed One's words.