Some centipede species live as long as five or six years. Habits Both millipedes and centipedes prefer very moist environments, such as under rocks, logs and boards, in plant litter, or underground but close to the surface. Occasionally, millipedes and centipedes will invade the home, if a moist, dark environment is available. Both are often found in cool compost piles and in greenhouses. The millipede's segments have a hard shell that protect it from predators when curled in a tight coil.
Some species also produce a smelly and bitter liquid from glands along their sides.
Centipedes have a soft shell, with no waxy protective coating, hence the need for a damp environment. Millipedes and centipedes use their legs to push through soil and leaf litter. Each leg has a claw that gives it purchase on the soil. Most millipedes just push themselves through the soil, but some species have different segment shapes, designed for wriggling or wedging their way. Technically, they feed on the bacteria and fungi that are decomposing the vegetation, but in chewing and excreting the litter, millipedes encourage more bacteria and fungi by breaking the litter into smaller pieces, with more sites for biota activity.