Black pepper should be kept in a tightly sealed glass container in a cool, dark, and dry place.

Whole peppers will keep almost indefinitely, while ground pepper will stay fresh for about three months.

Also, keep it without moisture. If moisture occurred then dried it into the sun and then you will get a fully dried black pepper.