https://github.com/0ekk/shell-sched
Simple concurrent task scheduler based on shell and few GNU tools
https://github.com/0ekk/shell-sched
bash concurrent scheduler
Last synced: 2 months ago
JSON representation
Simple concurrent task scheduler based on shell and few GNU tools
- Host: GitHub
- URL: https://github.com/0ekk/shell-sched
- Owner: 0ekk
- License: apache-2.0
- Created: 2023-04-02T07:32:25.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-15T10:43:39.000Z (about 2 years ago)
- Last Synced: 2024-12-26T00:07:01.714Z (over 1 year ago)
- Topics: bash, concurrent, scheduler
- Language: Shell
- Homepage:
- Size: 3.79 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
shell-sched is a simple concurrent task scheduler based on shell and few GNU tools.
## Features
- Concurrent and asynchronous
- Priority based schedule
- Dynamic tuning and slow start
- Less intrusion
[](https://asciinema.org/a/597018)
## Important
The scheduler can only be enabled when SCHED_ENABLED=1 (default).
If not, all task emited run serially as normal rather than exit with error.
## Usage example
If you want sleep 10 seconds in background:
# Import all things of sched.sh into current shell proccess.
source sched.sh
# Startup scheduler
sched::startup
# Emit a task to scheduler
sched::emit "sleep 10"
# Block current proccess for waiting tasks. Optional, if absent, tasks have still be running in background
sched::wait_all_tasks
# Shutdown scheduler
sched::shutdown
## Exposed environment variables
1. SCHED_ENABLED
Enable or disable scheduler
1 -> enable, 0 -> disable
2. SCHED_DATA_ROOT
Root path that stored intermediate data on runtime. Default is under /tmp that is generated automaticlly by runtime.
3. SCHED_MAX_RUNNERS
Max parrallel task counts. Must be great than 0. Default (2 * cpu cores)
4. SCHED_DEBUG
Enable or disable scheduler debug log
1 -> enable, 0 -> disable
# Exposed functions show as below:
1. sched::startup
Start scheduler
2. sched::shutdown
Stop scheduler
3. sched::emit \ [\]
Emit a task to scheduler which would select a task to execute asynchronously based on its priority
Note: task must be a function or one-line command
4. sched::wait_all_tasks_and_exit
Wait all tasks complete or any error occurred, and exit the calling proceess
5. sched::wait_all_tasks
Wait all tasks complete or any error occurred, only exit the calling proccess when error occurred