Is it possible to run a cron job randomly between 3-6 minutes?

Issue

I defined a cronjob with the whenever gem for Ruby. This created a cron job for the user that runs a ruby script every 5 minutes. The user is not root and doesn’t have root permissions.

I would like to be able to run this job randomly between 3-6 minutes. I’m running this job on CentOS 6.2

Solution

Just make the script run continuously with a random delay between actions. Put it in cron as @reboot and it will restart when the system does.

Answered By – John Zwinck

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published