Fisrt guess, bad thermocouple. It senses that there is fire and tells the gas valve all is OK. If it is malfunctioning, it will shut off the gas valve. Look at the burner unit, is it clean, free of rust and debris?? Is the thermocouple in the flame when it lights?? If the thermocouple is not in the flame, that is the same as not sensing fire.