A reciprocating compressor with a linear motor, comprising a piston (1) reciprocating inside a cylinder (2) having an end closed by a cylinder head (5) provided with suction and discharge orifices (5a, 5b), to which are operatively associated suction (6) and discharge (7) valves, wherein that it comprises a valve means (10) for restricting gas discharge mounted inside the cylinder (2) and having an operative position, seated against the discharge orifice (5b ) and sealing the discharge orifice (5b) at least partially, and an inoperative position, spaced from said discharge orifice, the operative position being defined when the top of the piston (1) is within a certain distance (D) from the cylinder head (5), said distance being defined, so that, at the end of the compression stroke of the piston (1), be reached inside the cylinder (2) a determined pressure that will result in a force on the piston (1) and which is sufficient to interrupt its compression stroke before impacting the cylinder head (5).