我在游牧民族中有这个定期任务。目的是nomad3
每 5 分钟在主机上运行一次脚本。我还在下面包含了脚本的内容。
job "periodic" {
datacenters = ["dc1"]
type = "batch"
periodic {
cron = "*/5 * * * * *"
prohibit_overlap = true
time_zone = "UTC"
}
group "periodic" {
count = 1
restart {
interval = "5m"
attempts = 10
delay = "25s"
mode = "delay"
}
task "cronjob-test" {
driver = "exec"
constraint {
attribute = "${node.unique.name}"
value = "nomad3"
}
config {
command = "/bin/bash"
args = ["/usr/local/bin/cronjob-test.sh"]
}
resources {
cpu = 100 # Mhz
memory = 10 # MB
network {
mbits = 10
# Request for a dynamic port
port "uptime" {
}
}
}
}
}
}
包含cronjob-test.sh
:
#!/usr/bin/env bash
DATE=$(date '+%F-%s')
touch /tmp/$DATE
该脚本位于 nomad host 上nomad3
。我应该看到/tmp
我在 bash 脚本中指定的格式的文件,但我没有看到这个。需要帮助了解正在发生的事情。