How to run cron job with Firebase?

后端 未结 6 1220
南笙
南笙 2020-12-01 16:49

I am trying to run a cron job with Firebase. Basically I need to run a function that makes a ton of API calls and pushes data to firebase at 12:00am PST every day. Is there

6条回答
  •  再見小時候
    2020-12-01 17:13

    At I/O 2019 it was announced a new feature to do cronjobs with firebase functions.

    Check it out

    • schedule-functions

    Snippet 1

    export scheduledFunction = functions.pubsub.schedule(‘every 5 minutes’).onRun((context) => {
      console.log(‘This will be run every 5 minutes!’);
    });
    

    Snippet 2

    exports.scheduleJobs = functions.pubsub.
    schedule(“every day 03:00”).onRun(async() => {
     // do something
    console.log(“All done! See you tomorrow morning!”);
    });
    

提交回复
热议问题