0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Ansibleのcronモジュールを使ってjobを登録してみた

Last updated at Posted at 2023-06-21

検証環境

コントロールノード・・・RHバージョン8.6にインストールしたansible 2.9.25を使っています
ターゲットノード ・・・RHバージョン8.6

検証内容

下記をrootユーザーのcronジョブとして登録する

曜日 実行ユーザー ジョブ ステータス
30 2 * * * root /var/maintenance_tool/db_backup.sh 有効

playbook

オプション 説明
*name キー、アクセスまたは編集するパラメーター名を指定します
minute 時間 (分)
hour 時間
day 日付
weekday ジョブを実行する曜日
job 実行するコマンド
user crontab を変更する必要がある特定のユーザー
disabled crontabでジョブをコメントアウトするか

※は必須項目

---
- name: cron db_backup
  cron:
    name: "db_backup"
    minute: "30"
    hour: "2"
    day:  "*"
    month: "*"
    weekday: "*"
    job: "sh /var/maintenance_tool/db_backup.sh"
    user: "root"
    disabled: "no"
  become: yes

実行結果

image.png
◇ポイント
nameで書いたものが、#Ansible:で設定される
image.png

参考サイト

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?