1 gas valves are sealed with grease sometimes this can block the pilot position, it could explain how sometimes it does work.
2 is it lighting but not staying when you release the knob, that would point to the thermocouple not recieving enough heat or being u/s
3 it could be a blocked main jet this can happen if you open roast a lot
Maestro
November 2008