If you buy anchovy paste in a tube, you measure out whatever you want, then screw the lid back on. I keep my tube in the cheese compartment in the fridge.
As several folks have pointed out, tomato paste freezes well. I have a couple of tiny plastic tupperware-type containers for leftovers like that.
Of course, DH just likes to dilute any leftover tomato paste down into tomato juice, give it a squirt of Tobasco sauce, and sip it while I'm cooking!