I have implemented whenever gem for my backend crons jobs which is working good when I try something like
every 2.seconds do
rake "my:rake:task"
end
I get this error
`parse_time': Time must be in minutes or higher (ArgumentError)
I really want to run this task after every few seconds how can I do this.
You cannot do this with the whenever
gem.
Under the hood, the whenever
gem simply creates a cron
job. These can only be configured at a minimum granularity of per-minute.
What you could do instead is write a shell script with an infinite loop that runs your task, and then sleeps for 2 seconds. However, I would advise against it - running something this frequently feels wrong. There's probably a much cleaner approach, e.g. running your code as an after_save
hook?