1
0
mirror of https://github.com/nxshock/gron.git synced 2024-11-27 03:41:00 +05:00
SystemD and cron inspired job scheduler
Go to file
2022-06-12 13:34:25 +05:00
tests Add sql execution 2022-05-10 19:44:41 +05:00
webui New updates 2022-03-30 21:06:55 +05:00
.gitattributes Initial commit 2022-03-26 13:23:39 +05:00
.gitignore Do not add log files 2022-05-10 21:29:15 +05:00
config.go Compact time format 2022-03-28 19:55:21 +05:00
consts.go Fix log formatter 2022-03-28 18:24:23 +05:00
db.go Add MS SQL database logging 2022-05-14 14:17:52 +05:00
go.mod Update database libs 2022-05-21 20:25:06 +05:00
go.sum Update database libs 2022-05-21 20:25:06 +05:00
gron.conf Compact time format 2022-03-28 19:55:21 +05:00
httpserver.go New updates 2022-03-30 21:06:55 +05:00
job_test.go Add sql execution 2022-05-10 19:44:41 +05:00
job.go Add OnErrorCmd and OnSuccessCmd callbacks 2022-06-12 13:34:25 +05:00
jobtype.go Add sql execution 2022-05-10 19:44:41 +05:00
LICENSE Initial commit 2022-03-26 13:23:39 +05:00
log.go Add LogWriter 2022-05-14 14:17:30 +05:00
main.go Write main log to stderr too 2022-05-14 14:16:49 +05:00
make.bat More changes 2022-03-27 12:39:24 +05:00
README.md Add OnErrorCmd and OnSuccessCmd callbacks 2022-06-12 13:34:25 +05:00
restartrule_test.go Add on error restart job options 2022-03-29 21:38:04 +05:00
restartrule.go Add on error restart job options 2022-03-29 21:38:04 +05:00
status.go New updates 2022-03-30 21:06:55 +05:00
template.go New updates 2022-03-30 21:06:55 +05:00

gron

SystemD and cron inspired job scheduler

Usage

  1. Create gron.d directory

  2. Create job config in gron.d/job1.conf (TOML format):

    Type                   = "cmd"        # command execution
    Cron                   = "* * * * *"  # cron instructions
    
    Command                = "echo Hello" # command to execute
    

    SQL job:

    Type                   = "sql"                            # sql execution
    Cron                   = "* * * * *"                      # cron instructions
    Description            = "execute procedure every minute" # job description
    
    Driver                 = "pgx"                            # "pgx" for Postgresql, "oracle" for Oracle, "sqlserver" for Microsoft SQL Server
    ConnectionString       = "postgres://login:password@host:port/database?sslmode=disable" # each driver has different syntax
    SqlText                = "CALL procedure"                 # command to execute
    

    Add other options if needed:

    Description            = "print Hello every minute" # job description
    NumberOfRestartAttemts = 3                          # number of restart attemts
    RestartSec             = 5                          # the time to sleep before restarting a job (seconds)
    RestartRule            = "on-error"                 # Configures whether the job shall be restarted when the job process exits
    
    OnSuccessCmd           = "echo 'Job finished.'"              # execute cmd on job success
    OnErrorCmd             = "echo 'Error occurred: $ErrorText'" # execute cmd on job error
    
  3. Launch gron binary

  4. HTTP interface available on http://127.0.0.1:9876