Skip to content
/ ezcron Public

cronを監視するための、コマンド・スクリプト用のラッパー

License

Notifications You must be signed in to change notification settings

abtoc/ezcron

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EzCron

test and build License: MIT

コマンド、スクリプト用のラッパーです。
crontabに加えることによって、crond上で動作するコマンド、スクリプトの管理がしやすくなります。
以下の機能があります。

  • ログ機能:コマンド、スクリプトの実行ごとにログを取得します。
  • 同時実行抑止:処理中は動作しないように制御します。
  • 終了通知:終了時のスクリプトが指定できます。指定したスクリプトで通知させることが可能です。

horensoを参考に作成しております。

インストール

curl -fsSL https://raw.githubusercontent.com/abtoc/ezcron/main/install.sh | sh

バージョンを指定してインストール

curl -fsSL https://raw.githubusercontent.com/abtoc/ezcron/main/install.sh | sh -s v0.1.0

使い方

ezcronを以下のようにcrontabに指定します。

* * * * * ezcron -r /path/to/report.sh job01 -- /path/to/yourscript1
0 0 * * * ezcron -r /path/to/report.sh job02 -- find /var/log/ezcron/ -type f -mtime +30 -exec rm {} \;

/etc/environmentに適切なパスが設定されtいるか確認して下さい。

ログは/var/log/ezlog配下に出力されます。

オプション

Usage: ezcron [OPTIONS] IDENTIFER -- args

Options:
    -r, --report SCRIPT reporting the result of process
    -n, --notify SCRIPT reporting the starting of process
    -e, --env NAME=VALUE
                        set environment variables
    -c, --config FILE   specifies the ezjob configuration file
                        (default '/etc/ezcron.toml')
    -w, --cwd DIRECTORY change current working directory
    -m, --multipled     allows concurrent execution
        --version       print version and close
    -h, --help          print this help menu and close

終了時のスクリプトについて

コマンド、スクリプト終了時に、指定したスクリプトを実行します。
指定したスクリプトのSTDINにJSONでデータを渡します。

ezcron -r ./report.sh TEST -- ls -al
{
  "identifer": "TEST",
  "uuid": "eccc87be-8141-40af-870c-c53b0bff6c11",
  "command": "ls -al",
  "args": [
    "ls",
    "-al"
  ],
  "exitcode": 0,
  "result": "process terminated code(0)",
  "pid": 629479,
  "log": "var/log/ezcron/20231211-005418-TEST.log",
  "status": "Finished",
  "start_at": "2023-12-11T00:54:18.063635555+09:00",
  "end_at": "2023-12-11T00:54:18.064889476+09:00"
}

ライセンス

MIT

作成者

あべとし

About

cronを監視するための、コマンド・スクリプト用のラッパー

Resources

License

Stars

Watchers

Forks