AWS CloudFormation用户数据中的Crontab [英] Crontab in AWS CloudFormation Userdata
本文介绍了AWS CloudFormation用户数据中的Crontab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用AWS CloudFormation用户数据时如何设置crontab?
How to set crontab when using AWS CloudFormation Userdata?
我正在设置
(crontab -l ; echo "0 * * * * wget -O - -q http://www.example.com/cron.php") | crontab -
但是cron没有设置。我应该使用一种特定的格式吗?
But the cron is not setting. Is there a specific format which I should be using?
推荐答案
这将起作用,在您的实例中为您的模板设置:
This will work, set this in your template, for your instance:
"UserData": {
"Fn::Base64": {
"Fn::Join": [
"",
[
"#!/bin/bash\n",
"echo '0 * * * * wget -O - -q http://www.example.com/cron.php' > /tmp/mycrontab.txt\n",
"sudo -u ubuntu bash -c 'crontab /tmp/mycrontab.txt'\n",
]
]
}
}
这篇关于AWS CloudFormation用户数据中的Crontab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文