Reputation: 45
How can i specify the timings for scheduling a task in sails-hook-schedule? I got this basic example from their docs.
module.exports.schedule = {
sailsInContext : true, //If sails is not as global and you want to have it in your task
tasks : {
//Every monday at 1am
firstTask : {
cron : "0 1 * * 1",
task : function (context, sails)
{
console.log("cron ok");
},
context : {}
}
}
};
Now what does this line means?
cron : "0 1 * * 1",
What i understood is that this is how i specify the timings for the schedule. I wanted to run a specific task at every 12 am in the morning. Can anyone help me with this?
Upvotes: 2
Views: 726
Reputation: 422
You can use this link - Cron Tab Guru to find out what the cron expression mean. It gives you the description of the cron expression. I find it very useful.
Upvotes: 0
Reputation: 3114
This string is a cron expression. Cron allows the users to schedule jobs to run periodically at fixed times, dates, or intervals in Unix-like computer OS.
You can find plenty of tutorials online to learn how to write one.
You've also got helpers to translate a cron expression in plain english, or to generate a cron expression.
The one you gave run the task
method on mondays at 1 am.
If you want to schedule it to run at 12 am on each morning, you can use this cron expression: 0 0 * * *
.
Upvotes: 1