Internal shocks in relativistic jets with time-dependent sources