I am fairly new to ubuntu/linux and python so I beg forgiveness in advance. I have a small python script that I typically start in a terminal screen. This script runs a simple task then sets a timer to run the same task again in 4 hours. I want to run this in the background and I also want it to start running when the server boots. I am sure this question has been asked before, but I have not had much luck finding the solution. Any help would be greatly appreciated. Basic cod below.
import os
import datetime
from threading import Timer
x = datetime.datetime.today()
if x.hour+4 > 23
do some stuff
else
do other stuff
Function()
Repeat above stuff
t = Timer(sec, Function)
t.start()