Different cooking oils stay fresh for different amounts of time, but you must treat them all well. They should be tightly covered and stored in the dark away from the heat (especially not in that handy cupboard over the stove). The less access they have to the air, the fresher they will stay. Refrigeration benefits most oils.
If unopened, peanut oil and corn oil and other vegetable oils will keep for at least a year. Once opened, they’re good for four to six months. But peanut oil, like olive oil, which is high in monounsaturates, benefits more from storage in the refrigerator. Olive oil will keep for about 6 months in the cool, dark pantry, but up to a year in the refrigerator. It may become cloudy and thicken up in the cold, in which case, letting it warm to room temperature will restore its pouring capacity. Walnut oil and sesame oil are delicate and inclined toward turning rancid. Kept in the refrigerator, they will stay fresh for two to four months.