Is there a way to refresh your path in Tor every x seconds or minutes without manually doing like pressing new identity? I need it to do it automatically (e.g. putting a line in the torrc file)? I looked online but couldn't find any information about this.
You may be looking for the torrc option MaxCircuitDirtiness, which defaults to 10 minutes.
This is assuming that you're doing something low-level, i.e. not using a browser, because the option only applies to new TCP connections. Existing connections don't get closed automatically!
Write a script (or maybe you can find a pre-made one) to loop a "NEWNYM"(New Identity) to the controller (port 9060). There's a built-in 10 second limit to how fast you can send a signal. But even that could be harsh on the network. So don't cycle so often/frequently.
I'd recommended using Stem (TOR's Python Library) to write your script. https://stem.torproject.org/