I'm pretty new to C++ so I'd like to ask for an advice on how to tackle this machine problem.

I'd like to create a program that will monitor activities and system time. (like it will execute something if the time is XXX, or it'll execute something if the user does YYY)

How can I create this one? should I create an infinite loop and constantly check time? or there are other efficient ways of doing this?

Thank you very much