November 6th, 2021, 2:28 pm
Perhaps too late to chime in, since answer probably found elsewhere.
However, just planting a "see also" in this thread.
Multiple prior responses on this thread are really talking about job control; which is not what the OP asked.
Depending on job control means incurring the process startup time, and your function will absolutely NOT be ready to fire at your requested time.
The correct and actual answer to the OP is to:
* spawn a child thread
* in that thread either:
- call a sleep function
- in other languages there may be some sort of setinterval function
* when that thread wakes up, it can either call the desired function directly or send a signal to a signal handler which invokes that function.
Whatever you do, in a workplace or other shared computing venue, please do not have a loop that spins and repeatedly checking:
"are we there yet?"
"are we there yet?"
"are we there yet?"
Since that is a good way to get the SysAdmin running down the hall asking who the hell is thrashing the server?!?!?
(I learned that firsthand)
All standard disclaimers apply, and then some.