Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dux/schedulero
Simple ruby scheduler
https://github.com/dux/schedulero
Last synced: about 2 months ago
JSON representation
Simple ruby scheduler
- Host: GitHub
- URL: https://github.com/dux/schedulero
- Owner: dux
- License: mit
- Created: 2018-03-07T23:56:50.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-23T09:46:11.000Z (almost 7 years ago)
- Last Synced: 2024-04-28T21:22:22.420Z (8 months ago)
- Language: Ruby
- Size: 11.7 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Simple scheduler
Runs tasks in intervals
### Example
* state_file: where to keep the state? defaults to ./tmp/schedulero.json
* log_file
* [default]: ./log/schedulero.log
* String: ./log/custom...
* FalseClass: no log```
require 'schedulero'# s = Schedulero.new state_file: "./tmp/schedulero.json", log_file: "./log/schedulero.json", silent: true, state: DRunnerbState
s = Schedulero.new
s.every 'Frequent job', 5 do
puts '5 seconds passed'
end# every day
s.every 'Slow job', 1.day do
puts 'day job ...'
end# at specfic hour of the day
# will run only once per hour
# at 'At times', 1 do # at 1AM
# midnight and 6 PM
s.at 'At times', [0, 18] do
p 'BINGO'
ends.run # run only once
s.run_forever # run thread forever
```### Instalation
`gem install schedulero`
Run jobs via cron every minute/hour. Jobs will run if needed.
`1 * * * * bin/bash -l -c 'ruby /users/me/jobs.rb'`
### Other info
* runs tasks in separate threads
* if the tasks are running before the start, they will be killed
* logs standard exceptions and runner info to log