Pesto will keep for up to 4 weeks in a covered container in the refrigerator. Pour a thin film of olive oil on top of the pesto to prevent discoloration and cover with plastic wrap.
I love to freeze pesto in ice cube trays. I like to spray an ice cube tray with non-stick spray and fill each space with the pesto. When frozen, remove each cube and store in a freezer bag. You will be able to take out as many of the pesto cubes as you need. Usually one cube is enough for adding flavor to a red pasta sauce or a pot of soup.