Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
Compare when was last time cronjob run

Background: I'm currently working alongside a FaaS provider that allows us to run in our app a Scheduled Trigger, basically it allows us to run a method on a schedule. The problem is they only give us 3 options: hour, week, year. That means that I can't run a method 4 times a day, 6 hours intervals.

I started thinking about implementing this logic with cron expression

const sixHourCron = new CronJob("0 */6 * * *", () => setScheduledTriggerInterval);

The function setScheduledTriggerInterval calls an api and verifies user status. This is also the function that gets called each hour by implementing the Scheduled Trigger as referred above. But I only want the function to run if it didn't run within the last 6 hours.

Is there a way of having something like this:

const setScheduledTriggerInterval = () => {
    //check last time function ran with global initialized crontime/cronjob?
    if 6 hours have passed
    run the job
    else return and do nothing
}

Note: I have to use the Scheduled Trigger functionality so timeout or intervals are unfortunately not an option

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!