Servo controlling function...

ok ,i want to tell a servo to work for specific time .for example
2 seconds and thenn the servo will stop ,or do something else
...