I'm not totally sure whether your question about a server side scheduled job or is asking about a timed function in an app. Here are answers for both.
For a Server-Side Scheduled Job
I think the best way to do what you want is going to be similar to cron. Basically what these "cron jobs" do is connect the system clock to a shell that will run commands at certain times or at a specific time interval. You load a file into a specific location and in the file you specify a list of Strings that will be run as arguments in a shell when the job fires, which basically allows you to run any program you want.
For Linux:
Use actual cron. You can find a good tutorial here.
For OS X:
Use .plist files similar to cron files. You can find a good tutorial here.
For Windows:
I think, but I am not sure, you can use the Windows Task Scheduler. Tutorial is here, but this pertains to Windows 7. I've personally never done this in Windows.
For a Timed Function in an App
In Swift
Swift makes it really easy to do something like this. Just use an NSTimer
.
To schedule a repeating timed function call in Swift:
var myTimer = NSTimer.scheduledTimerWithTimeInterval(MY_TIME_INTERVAL, target: myObjectContainingMyMethod, selector: "myMethod", userInfo: nil, repeats: true)
and you have a scheduled timer that repeats indefinitely. You can cancel the timer but calling
myTimer.invalidate()
For Java (Android)
It is a little more complicated. See this previous question for a good explanation.