Gas fireplace, pilot is off, push to ignite and it does but the flame comes on and it only stays lite for about 30 seconds and shuts down. I changed the batteries in the remote control. So not that.
There should be a metal-wire looking thing that is the thermocouple. It must be in the path of the pilot and getting hot when its lit. The thermocouple must come up to temperature before you release the hold down for the pilot and turn it to "ON".
Usually, the thermocouple either works or doesn't. It can be bent slightly to put it more in line with the pilot.
Its not an expensive part, and a good DIY repair.