For the characteristics of permanent magnet linear motor (PMLSM) servo system in machine tool feeding system suffering from the effect of parameter variations, load disturbances and so on, the time-varying sliding mode position and speed controller was designed. By designing the time-varying sliding mode line, the line is changing with time t and its slope does not change during the control process. And the error state of the control system always lies on the sliding mode line from the beginning of any initial state. The reaching phase is eliminated. During the design process, because of the control signal is restricted, optimize the controller parameters by minimizing the integral absolute error (IAE). And the convergence rate of error is speeded up. The simulation results prove that the system have global robustness to the parameter variations and disturbance.