The Shulhan Aruch (Orah Haim 328) writes that it is forbidden on Shabbat to run or engage in strenuous physical activity for the purpose of perspiring. People would induce sweat for healing purposes, and thus the Sages forbade intentionally inducing sweat on Shabbat just as they forbade taking medications out of concern that one might grind herbs to produce medicine.
The clear implication of the Shulhan Aruch’s ruling is that other forms of exercise, where the intention is not to induce sweat – such as light weightlifting – are permissible on Shabbat. A number of later Halachic authorities forbade all exercise on Shabbat because they felt that exercise falls under the category of "Ubdin De’hol" – weekday activity – but the Shulhan Aruch clearly felt otherwise. Accordingly, Hacham Ovadia Yosef ruled (in Yalkut Yosef) that strictly speaking, it is permissible to exercise on Shabbat if the intention is not to raise the heartrate and induce perspiration. Nevertheless, he adds that it is preferable to be stringent and to refrain from any form of exercise on Shabbat. Thus, Hacham Ovadia rules, one who normally jogs in order to increase his heartbeat and pulse, and build up a sweat, should not jug on Shabbat, but should instead take a short brisk walk if he wishes. Nonetheless, as long as the intention of running is not to sweat and perspire, it would be permissible from the law.
However, if a patient received instructions from his physician that he must exercise every day, including Shabbat, and the exercise he needs to do requires inducing perspiration, then he may do whatever the doctor instructed. Such a person is considered an ill patient, and the prohibition against health remedies on Shabbat apply only to generally healthy people who are not feeling well, but not to people with an illness. Therefore, a patient whose doctor instructed him or her to exercise on Shabbat may do whatever form of exercise is necessary.
It is entirely permissible to take a walk on Shabbat, even for health purposes, since this is something perfectly normal that healthy people do, as well.
Additionally, massages are permissible on Shabbat, as long as no cream is used, and as long as one does not receive a deep massage that induces sweat. However, Hacham Ovadia writes that if somebody experiences significant backpain or neck pain, he is allowed to receive a deep massage on Shabbat to alleviate the pain.
Summary: Exercise that is intended to raise the heartrate and induce perspiration is forbidden on Shabbat, unless for health reasons one has been instructed by a physician that he must do such exercise every day. Other forms exercise, which do not induce perspiration, are permissible, though it is preferable to refrain from all exercise on Shabbat. As long as the intention of running is not to sweat and perspire it would be permissible from the law. Walking is permissible, even if it is done for health purposes. Massages are allowed on Shabbat (without cream), though deep massages, which induce perspiration, are allowed only if one requires such a massage to alleviate considerable pain.