https://www.traccar.org/

The sad part is no Linux client, cause there is a lot of GPS modules USB type that work well in Linux. However
you can use an android client on Pi and do some magic, or turn smartphones into GPS.

It works but you need to get the right smartphone, the one that gives access to services and disables battery optimizations for apps and large battery.