|
2 years ago | |
---|---|---|
config | 2 years ago | |
configs | 2 years ago | |
debian | 2 years ago | |
website | 2 years ago | |
.gitignore | 2 years ago | |
build.sh | 2 years ago | |
config.go | 2 years ago | |
file_utils.go | 2 years ago | |
gogocron.go | 2 years ago | |
readme.md | 2 years ago | |
timing.go | 2 years ago |
Cron daemon with crontab syntax, small interval and execution timeout for each task. Report bugs here 21h@blindage.org.
Requires:
su
commandsu
command in $PATH
Check before that curl
and tee
installed.
curl http://deb.blindage.org/gpg-key.asc | sudo apt-key add -
echo "deb http://deb.blindage.org bionic main" | sudo tee /etc/apt/sources.list.d/21h.list
sudo apt install gogocron
You can find binary code in Releases tab or build code yourself.
Installation example (change download url to last release):
$ wget --content-disposition "https://git.blindage.org/attachments/deaaa74f-efbe-4254-bf10-18e108b81065"
$ dpkg -i gogocron-1.1.deb
$ systemctl enable gogocron
$ systemctl start gogocron
Install Golang, then build:
go get github.com/kr/pty
go get gopkg.in/yaml.v2
./build.sh
All global options loads once at daemon start and HUP signal have no effect on them, use restart command: systemctl restart gogocron
.
Run precision means how frequently gogocron checks that second was incremented. What this means to you? Answer is how fast task will run after new second begin + some delta time for filtering tasks to run. Default value is 100 ms, but if you lower this value the checking circle get more CPU resources because checks to be more frequent.
Edit /etc/gogocron/gogocron.yml
:
ticktack_precision: 100ms
Set location where tasks files stored.
Edit /etc/gogocron/gogocron.yml
:
tasks_location: /etc/gogocron/configs
gogocron reloads all tasks configurations after receiving HUP signal, use reload
or restart
command to apply new task configuration: systemctl reload gogocron
.
Set interval how often run task (whole batch of commands in task). Use traditional crontab syntax.
runsecond // second
runminute // minute
runhour // hour
rundom // day of month
runmonth // month
rundow // day of week
If whole task (not one command in task) running more than timeout cron send SIGTERM signal, by default timeout is turned off.
timeout: 3h12m4s
It's a golang's time.Duration definition, string:
By default if task's command not die after SIGTERM in 10s cron send SIGKILL signal. You may need this if your program receiving signals but internal queue not empty for immidiately stop.
You can change this time with:
gracefulstop: 30s
It's a golang's time.Duration definition, string:
Array of environment variables (strings). Defines additional to gogocron's env variables for each command in commands
array.
Syntax:
env:
- TESTVAR="test variable"
Array of commands (strings). Commands in one task running line by line with environment variables defined in ENV
.
Syntax:
commands:
- whoami
- sleep 3
- head -c 20 /dev/urandom |base64
- ls
- echo $TESTVAR
logtype
can accept:
You never see variable value because timeout kill this task earlier.
---
name: "Print base64 of 20 random symbols"
runsecond: "*/5"
logtype: info
timeout: 10s
user: vlad
env:
- TESTVAR="text you never see"
commands:
- whoami
- sleep 3
- head -c 20 /dev/urandom |base64
- ls
- sleep 10
- echo $TESTVAR