Handy script.

file <exe>
set pagination off
set breakpoint pending on
break exit
commands
run
end
run

Run it using:

gdb -x <script>