i am trying to make api which can generate attendance daily at 9:50Am it's only operate once but not daily
const server = app.listen(process.env.PORT, () => {
console.log(`Server is working on http://localhost:${process.env.PORT}`);
});
cron.schedule(
"24 10 * * *",
async () => {
let date = new Date();
date = date.toISOString().split("T")[0].split("-").reverse().join("/");
console.log("morning");
const Users = await Employee.find({ shift: "morning" });
console.log(Users);
Users.forEach(async (user) => {
const attendance = await Attendance.create({
user: user._id,
status: "absent",
date,
});
console.log(attendance);
});
},
{
scheduled: true,
timezone: "Asia/Karachi",
}
);
can anyone explain why it is not working on daily basis my server is live on heroku and how to fix this?