I don't know how to do the code for an rtc controlling a relay
You will most likely find nobody here, who will write the code for you, since this is not a free code writing service. But I will suggest a good way.


  I just need the relay to trigger every 4h for 5min


The phrase "every x hours" screams for using the modulo operator %. Modulo gives you the rest value of an integer division. See these values:

0 % 4 = 0
1 % 4 = 1
2 % 4 = 2
3 % 4 = 3
4 % 4 = 0
5 % 4 = 1
...
7 % 4 = 3
8 % 4 = 0


You see, the modulo 4 operation gives you zero every 4 hours starting with midnight. So make an if statement based on that

if(hour % 4 == 0 &amp;&amp; min == 0)


to switch on and

if(hour % 4 == 0 &amp;&amp; min == 5)


to switch off. Just change your code in this way and you are done.