Comments (13)
If you dont want to give the full date, you could try something like this:
every 1.month, :at => "start of the month at 9am"
This will produce the intended "0 9 1 * *". It will also keep your code a little cleaner :)
Hope that helps.
-AP
from whenever.
Ah, I see the problem (other than me not having good docs in this area). When you use :at with 1.month, the day, hour, and minute get parsed from the time. So when you just use a time like 9am, it assumes the day you mean is today.
One way to correct this is give it a full date. I admit that this looks ugly, but it should work: every 1.month, :at => "January 1st 9am"
It will ignore the "January", but it's necessary for a successful parse (Whenever uses the Chronic gem for parsing dates and times).
Hope that helps.
the
from whenever.
are you showing all of the cron output there? your first example has a 9 in the hour place and 18 in the day.
# .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # | | | | | # * * * * * command to be executed
from whenever.
no, the complete output was:
0 9 18 * * command
from whenever.
can you paste your schedule.rb file? something seems off.
from whenever.
every 1.month, :at => "9 AM" do
command "..."
end
from whenever.
Thanks Javan.
As you said, thats not good looking but it works!
from whenever.
tsommer...the above solution I posted should work. I'm not sure if you looked at it.
from whenever.
"start of the month at 9am" -- that rules! thanks.
from whenever.
I need to express this cron job "0 0 27-31 * *". Is it posible with the current syntax?
Maybe would be better to provide another method in the DSL to pass in cron jobs in the normal cron syntax, something like:
cron "0 0 27-31 * *" do # ... end
from whenever.
I agree that a raw syntax option would be nice (patches welcome!). In the meantime you can do this with a dash of Ruby.
every 1.month, :at => (27..31).to_a.map { |d| "12am January #{d}" } do
command "..."
end
from whenever.
Javan thanks for the fast response.
Currently I'm using the following patch. Maybe the regexp could need some improvements but it works for me now.
class Whenever::Output::Cron CRON_EXP = /[^\s]+\s[^\s+]\s[^\s]+\s[^\s]+\s[^\s]+/ def time_in_cron_syntax case @time when CRON_EXP then @time when Symbol then parse_symbol when String then parse_as_string else parse_time end end end
Then I can do:
every '0 0 27-31 * *' do ... end
from whenever.
how i create every 2 month, end of day(31th), 11 59pm do cron?
every 2.month, at 59 11 L * 0
from whenever.
Related Issues (20)
- Adding timeout to prevent overlapping cron jobs HOT 2
- Ruby raising "Operation not permitted -- ../bin/bundle (LoadError)" error
- AWS AL2 v3 - Source environment HOT 1
- Issue when using runner HOT 2
- Missing "script/runner", undocumented dependency on rails? HOT 2
- Incorrect crontab generated when using "days after/before"
- Support for every other hour with offset (1am, 3am, etc.) HOT 3
- Operation not permitted - getcwd (Errno::EPERM) HOT 4
- How to set the daily time as the time of a certain time zone, thank you HOT 1
- How to change the shell by default (bash) ? HOT 1
- How do I "namespace" the crontab entries?
- ActionView::Template::Error (undefined method `>' for nil:NilClass): HOT 1
- Ruby 3.2 autocompletion in console HOT 9
- We need to move from travis-ci to github actions
- How to execute multiple tasks with a single runner ? HOT 1
- whenever command is not working HOT 1
- [Feature Request] Add Dashboard for whenever cron job activity monitoring
- Bundler::RubyVersionMismatch HOT 1
- whenever -w throws incompatible library error HOT 1
- [Feature Request] Pass job frequency as argument to job
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from whenever.