I used these homemade (inexpensive) jigs to hold O gauge track for cutting with a hacksaw. One for straight, one for curved.
1. Cut grooves in a block of wood to accept a straight track. Make the block about 6 or 8 inches long, a couple of inches longer than you need for the straight piece.
2. Saw two one-inch sections off one end.
3. Glue or screw back sides of the two one-inch sections to another block with the curved track inserted on top, to keep the sections aligned. Keep the sections fairly close together in case you will need to cut an already short piece of curved track.
4. Insert track, place a block over the track, clamp it all in a vise to hold it, and hacksaw as needed.