Timer repeated function, Coroutine?

I am trying to create a function that runs on a set interval and updates a variable:

// Run this every set interval
void RepeatingFunction() {
     someVariable++;
}

I was wondering if this would be an opportunity to use a co-routine and WaitForSeconds? The problem is, I'm unsure as to how to make the function repeat, I tried this:

void Start() {
     StartCoroutine(RepeatingFunction());
}

private IEnumerator RepeatingFunction() {
     yield return new WaitForSeconds(pathfindFrequency);

     someVariable++;

     RepeatingFunction();
}

But unfortunately it doesn't work. Could anyone suggest as to how I can achieve this? For the record, it is part of a pathfinding script, I want to repeat the function so I can get the closest node every set interval.

You can use InvokeRepeating(). It is probably the easiest way.

void Start () {
     InvokeRepeating("RepeatingFunction", initalDelay, repeatTime);
}

void RepeatingFunction () {
     Debug.Log(Time.time);
     //Will print initialDelay + repeatTime * repetitions
}

The problem with your code was that you have to call StartCoroutine again to restart the function.

void Start() {
    StartCoroutine(RepeatingFunction());
}

IEnumerator RepeatingFunction () {
    yield return new WaitForSeconds(repeatTime);

    StartCoroutine( RepeatingFunction() );
}

BUT let me say that you shouldn't use recursion. It's a no no. Instead you should do an infinity loop.

void Start() {
    StartCoroutine( RepeatingFunction() );
}

IEnumerator RepeatingFunction () {
    while(true) {
          //execute code here.
          yield return new WaitForSeconds(repeatTime);
    }
}