I have this periodic task below in nomad. The purpose is to run a script on host nomad3
every 5 minutes. I've also included the contents of the script below.
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" {
}
}
}
}
}
}
with the cronjob-test.sh
containing:
#!/usr/bin/env bash
DATE=$(date '+%F-%s')
touch /tmp/$DATE
The script is on nomad host nomad3
. I'm supposed to see a file in /tmp
with the format I indicated in the bash script but I'm not seeing this. Need help on what is going on.