Shocks on a vehicle or truck should last a pretty long time and I have a truck that has 400,000 miles on it with the original shocks and they probably really should be replaced by now.
However I never have replaced the shocks on the truck yet.
When your ride becomes rough or you hear squeaking etc or your vehicle is riding low then it's usually time to replace shocks.
If you drive over bumpy roads a lot then you might need to replace the shocks more often than if you mostly ride on smooth roads.
The manufacture of most shocks recommend replacing the shocks at around 50,000 miles so you can replace them at 50,000 miles but it's not really needed unless you're having problems with the shocks.
You should easily get 100,000 to 200,000 miles easily out of a good set of shocks depending on how smooth and good the roads you're driving on are.