https://github.com/ariya/berkala
Run scheduled tasks
https://github.com/ariya/berkala
Last synced: 5 months ago
JSON representation
Run scheduled tasks
- Host: GitHub
- URL: https://github.com/ariya/berkala
- Owner: ariya
- License: mit
- Created: 2021-08-04T04:58:29.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-12T15:41:00.000Z (almost 4 years ago)
- Last Synced: 2025-04-25T03:18:26.513Z (5 months ago)
- Language: JavaScript
- Homepage:
- Size: 320 KB
- Stars: 31
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Berkala
[](https://github.com/ariya/berkala/blob/main/LICENSE)
[](https://github.com/ariya/berkala/actions)Berkala runs scheduled tasks specified in a YAML-based configuration.
To get started, first download the binary for your operating system from the [Releases page](https://github.com/ariya/berkala/releases). Unpack the ZIP file and run the executable.
Since a config file does not exist yet, you will be offered to create one.
Simply accept it and `berkala.yml` will be created, which may look like the following:```yml
tasks:# Without an explicit interval, the task runs immediately
boot:
steps:
- notify: Berkala starts nowstay-hydrated:
interval: every 1 hour
steps:
- notify: Drink some water! # TODO: how much?
- print: Reminder was sentlunch:
interval: at 11:58am
steps:
- notify: It's lunch time very soon
title: Important
- say: Get ready for lunchsign-of-life:
interval: every 2 hours
steps:
- run: ping -c 7 google.com
timeout-minutes: 2weekend-exercise:
cron: 0 9 * * 6 # every 9 morning on Saturday
steps:
- notify: Time for some exercises!
title: Stay healthy
```
Just like any regular YAML, everything from the `#` character until the end of the line will be ignored. Use this to insert comments.The schedule for each task can be specified as:
* [a human-friendly interval](https://breejs.github.io/later/parsers.html#text), e.g. `every 5 minutes`, `at 5pm`, or
* [a cron expression](https://crontab.guru/), e.g. `0 9 * * 6`If neither is explicitly stated, then the task runs right away.
Each task consists of one or more steps.
Every step must be one of the following:
run
: executes a shell commandExample:
```yaml
sign-of-life:
interval: every 30 minutes
steps:
- run: ping -c 7 google.com
```
Optionally, `timeout-minutes` can be used to limit the execution time and `working-directory` can be used to set the directory to start the execution from.Another example:
```yaml
sys-resource:
interval: every 2 hours
steps:
- run: |
date >> resources.log
top | head -n 4 >> resources.log
timeout-minutes: 3
working-directory: /var/log
```
Example:
```yaml
morning:
interval: at 7:00am
steps:
- print: Good morning!
```
notify
: sends a desktop notificationOptionally, `title` can be used to set the notification title.
Example:
```yaml
mahlzeit:
interval: at 11:58am
steps:
- notify: It's lunch time very soon
title: Yummy
```The notification is supported on the following system:
* Windows: [Windows.UI.Notifications](https://docs.microsoft.com/en-us/uwp/api/windows.ui.notifications.toastnotification) via [Powershell scripting](https://docs.microsoft.com/en-us/powershell/scripting)
* macOS: `display notification` with [AppleScript](https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_cmds.html)
* Linux: [notify-send](https://www.commandlinux.com/man-page/man1/notify-send.1.html), e.g. part of `libnotify-bin` package on Debian/Ubuntu
say
: converts text to audible speechExample:
```yaml
vaya-con-dios:
interval: 0 17 * * 1-5 # every workday late afternoon
steps:
- say: Time to go home
```The text-to-speech conversion is supported on the following system:
* Windows: [System.Speech.Synthesis](https://docs.microsoft.com/en-us/dotnet/api/system.speech.synthesis) via [Powershell scripting](https://docs.microsoft.com/en-us/powershell/scripting)
* macOS: `say` with [AppleScript](https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_cmds.html)
* Linux: [Festival speech synthesis](https://www.cstr.ed.ac.uk/projects/festival/), e.g. `festival` and `festvox-kallpc16k` on Debian/UbuntuFound a problem or have a new idea? File [an issue](https://github.com/ariya/berkala/issues)!
Alternative way to run Berkala (with Node.js)
With [Node.js](https://nodejs.org/) v14 or later (that has [npx](https://www.npmjs.com/package/npx)):
```bash
npx @ariya/berkala
```To run the development version, check out this repo and then:
```bash
npm install
npm start
```[](https://www.npmjs.com/package/@ariya/berkala)
[](https://bundlephobia.com/result?p=@ariya/berkala)