I am working on cloud functions especially schedule functions. I need to trigger a function periodically each 5 minutes, but in only test step. I need to run it on pubsub em
As you said, you can use firebase shell to run your function once. And in firebase shell, you can use NodeJS commands.
Inside firebase functions:shell
, use setInterval
to run your function every 2 minutes.
user@laptop:~$ firebase functions:shell
✔ functions: functions emulator started at http://localhost:5000
i functions: Loaded functions: myScheduledFunction
firebase > setInterval(() => myScheduledFunction(), 120000)
> this runs every 2 minutes
In Bash, you can even pipe the setInterval
command to firebase shell
user@laptop:~$ echo "setInterval(() => myScheduledFunction(), 120000)" | firebase functions:shell