The Prophet (peace and blessings be upon him) is reported to have said, “When a person dies, all his deeds come to an end except three: ongoing charity, beneficial knowledge (which he has left behind), or a righteous child who will pray for him.”
Knowledge, in its comprehensive sense, is what benefits people and does not conflict with morals and ethics of Islam. So, beneficial knowledge can be represented in any way and it is not a condition to be a teacher as a job. It can be represented in writing good books or articles of great benefit to people. It can also be in teaching the Glorious Qur’an and the good morals and behaviors of Islam to your children, wife, neighbors, etc.
Ongoing Charity (sadaqah jariyah) is that which continues in producing goodness for people. For example, if you donate even a few pounds for the establishment of a school, charitable hospital, mosque, etc, you will still gain rewards due to that ongoing charity even after death. So, you can make an ongoing charity in your life and thus its reward will still reach you after death. You can also leave a will for your children or any of your relatives to give out some of your estate as ongoing charity as elaborated above. But this should not exceed one third of your property.
With the above in mind, you can do any of the above-mentioned means or acts that can benefit you after death.!