A deferred task selects a task to run only if run_at <= current time. Refer to DJ request for job selection
SELECT `delayed_jobs`.* FROM `delayed_jobs` WHERE ((run_at <= '2016-09-27 00:49:59' AND (locked_at IS NULL OR locked_at < '2016-09-27 00:24:59') OR locked_by = 'host:Madhubalans-Air pid:74314') AND failed_at IS NULL) ORDER BY priority ASC, run_at ASC LIMIT 1
Your code sets run_at until 2016-10-18 00:00:00 and 2016-10-18 23:59:59. This way your code will work as you expect :)
source share