I currently have an Azure Function which runs on a schedule dictated by a CRON expression in the function itself.
For business reasons I now want to have this Function run on an HTTP trigger, sent by a Logic App.
The problem is that I can't see how to schedule the Logic App using a CRON expression. The Logic App's Recurrence mechanism permits me to specify a period based on one denomination of time, i.e. every x hours, minutes, etc.
Is it possible to specify, for example, the schedule described by this CRON expression:
0 30 0-5,13-23 * * 0-6
As far as I know, we can't set cron expression in azure logic app, you can set your Recurrence in this way, please set your Frequency to week:
I found that someone has put forward this suggestion in the feedback, you can vote for him, the development team will pay attention:
https://feedback.azure.com/forums/287593-logic-apps/suggestions/19597768-timer-trigger-cron-scheduling
Related
Hi I want to create a payment plan expiry reminder using django
Current Solution
Create a management command
Run the management command as a cron job
Problems with the Current sollution
in windows cron job doesn't work
it will run at particular time for all the users
I don't want to run cron for every minute
But i want to notify the user when 50%,30%,20%,10% and 5% time is remaining.
What I'm looking for
I'm trying to do something that can be done using the expiry_date ('available in the membership model of user and plan ')
using which we can just look at the membership which are expiring and notify them only.
final and most important i don't want to run a cron job every minute , but want to achieve a functionality which lets the user even remind that you have just 10mins remaining ,5 mins remaining kind of notifications.
as the process is for learning I'm not looking for any paid API's
I am new to nodeJs.
I am developing a platform where users can subscribe in trial or pro version. I would like to know if I can use the setTimeout method to delete a user's info from db after the subscription expiration date. if this is not possible is there a way to do it or a library that allows you to manage subscriptions?
You can, but it would not be a good approach since you be manging that on memory and if your server restarts you will lose this subscription status.
Why don't you just save on database the subscription date and on user login verify if the subscription date difference from the now is greater than the period of free subscription?
A solution to your problem is to run a CRON job. That may run once every 24 hours to check user's subscription's and if trial has expired then delete the user. You can use the cron npm package to achieve this.
setTimeout is not reliable, service can go up or down and your request should be persistent.
You need an offline job manager, DB-based, like agenda or similar.
Question is also discussed widely here: I need a Nodejs scheduler that allows for tasks at different intervals
Other solution: create TTL Index. Mongodb periodically checks and remove expired users.
You don't need to write any extra code / logic.
I want to send a push notification to a user after it's registration using FCM.
At the following times
after 5 mins of registration
after 24 hours of registration
after 1 week of registration
Thanks for your help in advance 🙏🏼
const schedule = require('node-schedule');
let scheduleDate = new Date(Some date)
schedule.scheduleJob(scheduleDate, function(fcmtoken){
SendNotificationhere(fcmtoken)
}.bind(null,fcmtoken))
If any doubt do mention your doubts in the comment section.
Sending 5 minutes after registration can be done with setInterval. But for 24hours and 1 week you need to have some cron job running. You can use something node-schedule as suggested by #PratapSharma.
Since you won't have cron job for individual user. You need to have a cron job running every hour or so, which will check user registration time and based on difference send particular notification. You can fetch users which are registered within last few days, in your case it will be 7 days.
This approach will have variation of 59 minutes from actual time (in case of 24 hours or 7 days). You can make your diffing mechanism smarter. Probably include users between 23.5 hours to 24.5 hours. Similar approach you can take for 7 days.
I am dealing with subscriptions where a user is subscribed to a plan and it has an expiration.
So basically each user store has an expiration field.
I want to be able to get notified when a user plan is expired as soon as it is actually expired.
Right now, I have a job that runs on all users once a day and check if anyone has expired but ideally I would like to get a server postback or some sort of event whenever a user is expired without running this each day.
Can you think of any third party service / database / other tool that deals with these sort of things ?
A lot of services, Stripe for example, notify you with a webhook whenever a user's subscription is renewed / expired. Are they just running a job repeatedly like I am ?
Hope I made myself clear enough, would appreciate help in how to focus my search in Google as well.
My current stack is Mongodb, Node.js, AWS
Thanks
We do not know for sure, how Stripe handles it.
There are two solutions coming to my mind. Let's start with the simple one:
Cronjob
As you mentioned, you already have a Cronjob solution, but you can instead make it run each hour, or each 10 minutes. Just ensure you optimize your query to the maximum, so that it is not super-heavy to run.
It is attractive, easy to implement, very few edge cases, but as you might have though can be a performance drag once you reach millions of clients.
Timers
Implementation varries, and you need to worry about the edge cases, but the concept:
On day start* (00:00) query for all clients who are set to expire today, save them into array (in-memory). Sort the array by time (preferably descending).
Create timer to execute on last array's element time.
Function: If Client X expires now, query database to ensure subscription was not extended. Notify if it wasn't.
Remove Client X from the tracked array. Repeat step 2.
On day start* - Also run it on script launch.
I am using Apigee Usergrid to create a car service database. My scenario is as such.
A customer can book his car for a service with his mobile app. This creates a service request in the car service db .
Now, many a times, the customers do not turn up on the booked date and time. In such a case, I want to mark the slot NO-SHOW as soon the stipulated date and time gets over.
As of now, I have a job that runs every day to clear up all such no-shows. But now, we have a requirement to mark such slots NO-SHOW almost as soon as the stipulated hour + 2 passes by.
E.g. if the reservation is on 24th Sept at 0900hrs and the car owner doesn't show up even after 1100hrs, the reservation booking has to be marked NO-SHOW.
Is there a way to achieve this implicitly in user grid?
Unfortunately this isn't available out of the box. You might try wiring up a Node.js service in Edge (enterprise.apigee.com) to do this?