How Can I run a part of code or script each 2 minutes


Is there an scheduling or interval settings to run a script or part of code each 1 or 2 minutes?



Hi, could you please explain what you’re trying to do that makes this useful?

setInterval( () => { 
     }, 1000 * 60 * 3);

Theres the way to do it, but as @luukschoen said might be better to see the context for what you need it, to find a better solution than this.


This ugly way is a solution for push notification replacement(In Iran is not working properly) and also updating Geolocation because I couldn’t solution to this problem:


Puting this code in homepage.ts or app.componnent.ts is better placement.?


Well I would make a provider for it and then wrap it inside and then call the provider from the app.componnent.ts when the platform is ready.

But essentialy yes, I would call it from the app.component.ts.


Thank you so much. this is temporary solves my problem.


No problem, good luck!