Being stuck in a dead end job by your early 40s is bad for your health.
Having an unrewarding job as you start out on the career ladder makes you more depressed, worried and had more trouble sleeping.
And if you stay stuck in positions with low levels of job satisfaction it affects you not just you mentally but physically too, including catching more colds, having a bad back and poor heart health.
But if you are happy in your job or finally get your dream job as your career progresses your overall health gets a boost.
The study by Ohio State University sociologists found job satisfaction in your late 20s and 30s has a link to overall health in your early 40s.
While it impacts on physical health, its effect was particularly strong for mental health.
Lead author and doctoral student Jonathan Dirlam said: "We found that there is a cumulative effect of job satisfaction on health that appears as early as your 40s."
The study highlighted the importance that early jobs have on people's lives.
Associate professor of sociology Dr Hui Zheng said: "You don't have to be near the end of your career to see the health impact of job satisfaction, particularly on your mental health.
"The higher levels of mental health problems for those with low job satisfaction may be a precursor to future physical problems.
"Increased anxiety and depression could lead to cardiovascular or other health problems that won't show up until they are older."
He added the study was carried out before the credit crunch and said: "The recession almost certainly increased job insecurity and dissatisfaction, and that could have resulted in more negative health effects."
The study used data from 6,432 Americans followed from the ages of 14 to 22 as part of the National Longitudinal Survey of Youth 1979.
Researchers examined job satisfaction trajectories for people from age 25 to 39 and their health on turning 40.
Participants rated how much they liked their jobs from 1 - dislike very much - to 4 -like very much.
They were then divided into four groups: consistently low and consistently high job satisfaction, those whose satisfaction started high but was trending down and those who started low but were trending higher.
About 45 per cent of participants had consistently low job satisfaction, while another 23 per cent had levels that were trending downward through their early career.
About 15 per cent of people were consistently happy at their jobs and about 17 per cent were trending upward.
Mental health was most affected by people's feelings about their jobs with those in the low job satisfaction group throughout their early careers scored worse on all five of the mental health measures studied.
They reported higher levels of depression, sleep problems and excessive worry and were more likely to have been diagnosed with emotional problems and scored lower on a test of overall mental health.
Those whose job satisfaction decreased were more likely than those with consistently high satisfaction to have frequent trouble sleeping and excessive worry, and had lower scores for overall mental health.
But they didn't see an impact on depression scores or their probability of being diagnosed with emotional problems.
Those whose scores went up through the early career years did not see any comparative health problems.
Those in the low satisfaction group and those who were trending downwards reported poorer overall health and more problems like back pain and frequent colds compared to the high satisfaction group.
But they weren't different in physical functioning and in doctor-diagnosed health problems such as diabetes and cancer.
As with mental health, no effects were seen on physical health for those trending upward.
The findings was presented at the annual meeting of the American Sociological Association in Seattle.