LoginSignup
6
3

More than 5 years have passed since last update.

EC2にansibleのcronモジュールを使ってcronを設定する方法

Last updated at Posted at 2017-05-30

ansible cronモジュール 

main.yml
---
- cron:
    name: "cronモジュールテスト"
    minute: "*"
    hour: "*"
    day: "*"
    month: "*" 
    weekday: "*"
    job: "ls -alh > /dev/null"
    state: present

実行結果(crontab -l)

#Ansible: cronモジュールテスト
* * * * * ls -alh > /dev/null

デフォルトでは、rootユーザーでcrontabが設定される仕様なので、
動作確認する際は、rootユーザーで確認する必要があります。

なお、実行ユーザーを指定したい場合は、オプションで「user」を指定する必要があります。

下記の公式ドキュメントに、詳しく書いてあります。

公式ドキュメント

6
3
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
6
3