简体   繁体   中英

Schedule tasks for each client on relative timezone in Android & iOS with NodeJS backend

I have a mobile app (native Android & iOS) which requires client's data to be updated (to renew the recurring items) daily at midnight. I'm using cron-jobs in nodejs using node-cron library and its working perfectly fine as it should. BUT the main problem I'm facing with this is of timezones ie data should be updated when clock struck midnight at "Client side" (wherever they are) but cron runs according to "Server time". So it works for some clients but fails for many...

I want to know is there any way I can achieve this at client side (by hitting a web service at specific time) or directly from server? My developer suggested me to save client's timezone in database and run cron separately for each client according to their timezone but I don't agree with this idea as I think it would be too much heavier for server to handle so many jobs simultaneously.

I need professional & expert opinions for this. Should I go for latter or any other way?

You could save the client timezone and make your cron run hourly, on each run it selects only the clients where it's midnight on their timezone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM