-1

How can I specify start and end of the job?

example execute every 5 minutes start at 5am and end at 10pm. Is this possible in whenever?

Andrew Marshall
  • 95,083
  • 20
  • 220
  • 214
Chris Ian
  • 771
  • 1
  • 7
  • 19

1 Answers1

0

The Cron syntax for this would be

*/5 5-22 * * * sh ./script.sh

Explanation

 */5 5-22 * * * sh ./script.sh
  \   \    \ \ \_every week day
   \   \    \ \__every month
    \   \    \___every day
     \   \_______every hour between 0500 (5 AM) and 2200 (10 PM)
      \__________every 5 minutes

Here's how to do it in whenever

# schedule.rb

every '*/5 5-22 * * *' do
  command "echo 'crontab syntax is useful'"
end
Mulan
  • 129,518
  • 31
  • 228
  • 259
  • good answer but i want to used whenever gem so that i will not maintain the crontab by itself. I want to update using rails gem – Chris Ian Jul 31 '13 at 01:52
  • Please see my edit for how to accomplish this using the whenever gem. – Mulan Jul 31 '13 at 02:02