I have a script that send an email to specific customer but what I'm trying to do is to fire that email in a given time and date .. so the solution is to use cron module
like below and changing the parameters with what I want
cron.schedule("* * * * * " , function(){
}
the problem that I want to modify those parameters with varibales which contains a result for a specific calculation! like this below
const X = 234;// this values will change everyday automatically
cron.schedule("X * * * * " , function(){
}
so is it possible to do something like that or is there a better solution that allows me to modify cron parameters
the solution that I tried but nothing is working is below :
const x = 40;// 40 seconds
cron.schedule(`${x} * * * *`, function(){
}
Best Regards,
Many Thanks to num8er ,
the only solution for my problem is
Simply save to table
jobs
the stuff need to do and put cron script to run every minute which will checkjobs table
and will run what is scheduled by time. Exampletable: jobs [id, runAt, method, arguments, done]
, cron will run and will take jobs which is not done andrunAt
is less than now, will run method and pass arguments to it and after finishing it will set done=truethat's enough simple to achieve: 1 insert to table, 1 method that will run by cron and get jobs from table and execute