Cron作业发送推送通知

I'm looking for the most solid solution for this scenario:

Server 1 serves a XML updated every 15 seconds (or less) with live sport events (this like goals, halftime, match end).

I'm using OneSignal API to send push notifications to the users of my App (iOS and Android) each time the XML brings something new.

So, what would be better?:

  • A cron job with a PHP file, reading the XML and triggering the push notifications when there's something new?
  • Something like Node will be better?

The thing that makes me worry is that if the cron job runs every, say, 10 seconds, it may fail sooner or latter.

So, anyone can advise in the most solid solution to do this? Thanks.

The cron itself cannot do what you want to do. You can create your own routine. The use of sleep (but this will not give the correct results, as it does not take into account the time required to run the command).
Cron only allows for a minimum of one minute.
You can consider writing a shell script with an infinite loop that runs your task, and then sleeps for x seconds, but as I said before is not accurate.



Edit: Here you can see how to make a shell script link1