You should know the ways and habits of the mind through daily introspection, self-analysis or self-examination. You should have knowledge of the laws of the mind. Then it will be easy for you to check the mind-wandering. When you sit for meditation, when you deliberately attempt to forget the worldly objects, all sorts of worldly thoughts irrelevant and nonsensical thoughts, will crop up in your mind and, disturb your meditation. You will be quite astonished. Old thoughts which you entertained several years ago, old memories of past enjoyments will bubble up and force the mind to wander in all directions. You will find that the trapdoor of the vast magazine of thoughts and memories within the subconscious mind is opened or the lid of the storehouse of thoughts within is lifted up and the thoughts gush out in a continuous stream. The more you attempt to still them the more they will bubble up with redoubled force and strength.
Do not be discouraged. Nil desperandum. Never despair. Through regular and constant meditation you can purify the subconscious mind and can control all thoughts and memories. The fire of meditation will burn all thoughts. Be sure of this. Meditation is a potent antidote to annihilate the poisonous worldly thoughts. Be assured of this.
During introspection you can clearly observe the shiftings of the mind from one line of thought to another. Herein lies a change for you to mould the mind properly and direct the thoughts and the mental energy in the Divine Channel. You can rearrange the thoughts, make new association on a new Sattvic basis. You can throw out useless worldly thoughts just as you remove the weeds and throw them out. You can cultivate sublime, Divine thoughts in the Divine garden of your mind or Antahkarana. This is a very patient work. This is a stupendous task indeed. But for a Yogi of self-determination, who has the grace of the Lord and iron-will, it is nothing.
Meditation on the Immortal Self will act like a dynamite and blow up all thoughts and memories in the subconscious mind. If the thoughts trouble you much, do not suppress them by force. Be a silent witness as in a bioscope. They will subside gradually. Then try to root them out through regular silent meditation.
The practice must be constant. Then only one can attain Self-realisation, surely and quickly. He who practises meditation by fits and starts for a few minutes daily will not be able to achieve any tangible result in Yoga.
How can sense-control be tested in a lonely forest, where there are no temptations? The Yogic student of the cave (seclusion) should test himself after growing sufficiently by entering the plains. But he should not test himself every now and then like the man who removed the young plant daily after watering to see if it had struck deep root or not.
May you all attain success in Yoga and enter into Nirvikalpa Samadhi or the Blissful Union with the Lord by controlling the senses and the mind and practising regular and constant meditation.
(pgs. 109-110, Concentration and Meditation by Swami Sivananda)