Get location in background service

Is it possible to somehow get a location in the background service without showing or interacting with any foreground widget or app? 

I want to create a background daemon that records my location throughout the day (e.g., once every hour) — something like Google History in maps. Showing notification or needing interaction with the user would be very annoying.