Rails-Schedule on tuesday and friday using whenever - ruby-on-rails

I am using whenever for scheduling in my rails app.
I could not find how to run my cronjobs on every tuesday and friday of the week anywhere in the gem's documentation.
This is what I am doing right now is this correct?
every [:tuesday, :friday], at: '12:00am', :roles => [:my_role] do
runner "User.notify"
end

You can use the plain crontab syntax in the schedule.rb
every '0 0 * * 2,5', :roles => [:my_role] do
runner "User.notify"
end
'0 0 * * 2,5' - β€œAt 12:00 on Tuesday and Friday.”
It's pretty simple:
Minute Hour Day of Month Month Day of Week
(0-59) (0-23) (1-31) (1-12 or Jan-Dec) (0-6 or Sun-Sat)
0 0 * * 2,5
Refs for help 1, 2

Related

Sidekiq Scheduler - Rails - Run a Worker On 2nd of every Month

Using sidekiq-scheduler, how can we schedule a worker to run 2nd of every month on a specified time?
import_worker:
every: '0 0 * 1 *'
class: ImportWorker
queue: scheduler
enabled: true
Will the above cron run every one month? Also how can I specify time here?
You want cron, not every. cron format is minute, hour, day of month, month, day of week. 0 0 * 1 * says to run every day of January at midnight. To run on the 2nd of every month at 12:30 would be 30 12 2 * *.
import_worker:
cron: '30 12 2 * *'
class: ImportWorker
queue: scheduler

How to schedule jenkins to start every day between 6PM to 7AM and on frieday and saterday run every 30 minutes

I am trying to schedule a jenkins build with the following:
start every day between 6PM to 7AM and on Friday and Saturday run every 30 minutes... but it seems for some reason a little bit hard.
Any help will be appreciates.
So I used 2 different jobs:
first is:
H/30 * * * 5-6 - every hour at weekend (Friday and Saturday)
H/60 18,7 * * 0-5 - Every hour between 18:00 to 7:00 on working days
You can do this by checking "Build periodically" and entering the following:
# Run every thirty minutes for the 48 hours of Friday and Saturday
H/30 * * * 5-6
# Run once per hour, between 18:00 and 06:59, on Mon,Tue,Wed,Thu,Fri
H 18-6 * * 1-5
Note also that this second expression will not run from Friday 6pm until Saturday 7am β€” it will stop at midnight, and resume again on Monday morning between midnight and 7am.

In Whenever gem, if we use every :month, does it mean the end of month or beginning?

When using the whenever gem we can set a monthly job like this :
every :month do
...
end
Will this run the job at the end of the month or at the start of the month? I want to run it at the end.
From the tests in whenever repo:
assert_equal '0 0 1 * *', parse_time(:month)
So :month will generate a cron entry that looks like 0 0 1 * *..
This corresponds to run once a month at midnight of the first day of the month.
One way to make the job run last day of the month would be to use the raw cron entry in wherever as follows:
every '0 0 L * *' do
...
end
This assumes that the cron on the server supports the L flag for representing the last day of the month.
See Cron job to run on the last day of the month for more about running a cron job on the last day of the month.

rails:whenever gem:run job every year

How can I write cronjob using whenever gem in rails 4.0 for last day of every year or any specific day of every year.
for ex. 31st dec, 11:59 pm of every year or 15th july of every year.
i am trying this,
every 1.year do
rake "namespace:jobname"
end
but where to mention day and time?
Please help, Thanks in advance.
For 31st dec, 11:59 pm,try this
every 1.year, :at => 'December 31th 11:59pm' do
rake "namespace:jobname"
end
For 15th july,try this
every 1.year, :at => 'July 15th' do
rake "namespace:jobname"
end
OR
every '0 0 15 7 *' do
rake "namespace:jobname"
end
Source
Note: Didn't tested.

using whenever gem for scheduling a job every hour on Sunday

We are using whenever gem on our rails project and there is one task that need to be run every hour but only on the day of the sunday.
I understand that i can schedule tasks on hourly basis , by something like this:
every 1.hour do
# do something
end
and i also understand that i can schedule it for a particular time on sunday:
every :sunday, :at => "11:00pm" do
#do something
end
what i am looking for is some syntax to schedule this task for every hour on sunday.
You could do something like that
every '0 * * * 7' do
#...
end
The '0 * * * 7' part is cron syntax:
0 - minutes
first asterisk - every hour
second asterisk - every day
third asterisk - every month
7 - on sundays (7th day of the week)
EDIT - For more detailed information regarding cron tasks syntax, a very clear article can be found here: http://www.thesitewizard.com/general/set-cron-job.shtml

Resources