Objectives Shift work is a risk factor for chronic diseases, and physical inactivity can have an influence on this association. We examined whether intra-individual changes in working time characteristics were associated with changes in physical inactivity and examined the risk factors for physical inactivity among shift workers in a 17-year longitudinal study cohort. Methods Study participants were 95 177 employees from the Finnish public sector. Work schedule information was based on questionnaire responses and additional register-based working time characteristics for 26 042 employees. The associations between working time characteristics and physical inactivity were examined using a fixed-effects logistic model. To investigate the risk factors for physical inactivity among shift workers, the odds ratios (OR) of worktime control and having small children were calculated. Results Compared with day work, shift work without night shifts was associated with physical inactivity among men [OR 1.38, 95% confidence interval (CI) 1.09-1.74], whereas shift work with night shifts was negatively associated with physical inactivity among women (OR 0.85, 95% CI 0.76-0.96). Register-based working time data confirmed that workers with a higher percentage of night shifts had a lower risk of physical inactivity. Having small children was associated with physical inactivity among shift workers (OR 1.47, 95% CI 1.32-1.65). Conclusions Both survey and objective working hour data revealed that workers having work schedules with night shifts were more likely to be physically active. Having small children was a risk factor for physical inactivity among shift workers.