The hardest part of curing tuberculosis, doctors say, is getting patients to take all their pills every day for at least six months. Even the easiest regimens of four antibiotics can cause nausea, fevers, rashes and stomach pain.

Health officials have tried many ways to persuade patients to comply, from gentle encouragement to imprisonment in locked wards. Now researchers have come up with a new tactic: A program based on nagging cellphone texts succeeded in goading patients into taking their drugs in a preliminary test in Nairobi, Kenya, according to a study published on Wednesday in the New England Journal of Medicine.

Patients who were enrolled in the phone program experienced 68 percent fewer bad outcomes — death, treatment failure or loss of contact with the clinic — compared to patients who were not.

Programs that send one-way reminders telling people to take pills, use mosquito nets or get their children vaccinated are common in Africa, but they do not work very well. The new program, called Keheala and created by a company with the same name, asks patients each day to actively verify that they have taken their pills.