Think internal combustion engine piston.

A connecting rod attached to a flywheel will provide the motion you need. Sealed bearings and lubrication of the sliding assembly, and it will last forever.