job does not seem to run at appropriate interval
I ran the following command:
mantra "* * * * * *" echo hahahahaha >> haha.log 2>&1 &
I expected it to run once a minute and append a single line to the log file. However, it immediately output 5 lines. Then a moment later there were 48, now a few minutes after the command, there are 148 lines.
Is mantra using some variation on standard crontab syntax that I am not aware of?
Also it does not seem to be running when I specify minutes and hours:
root@60173c4f370c:/haha# mantra
2018/10/18 18:34:15 Usage: mantra cron_spec cmd [ args ... ]
root@60173c4f370c:/haha# mantra "36 18 * * * *" echo haha >> haha.log 2>&1 &
...
root@60173c4f370c:/haha# mantra
2018/10/18 18:36:18 Usage: mantra cron_spec cmd [ args ... ]
root@60173c4f370c:/haha# wc -l haha.log
0 haha.log
I thought this might be an issue with flushing output streams, so I tried with a command other than echo. I ran this script (test.sh):
#!/bin/bash
date
rm -f outputfile
mantra "* * * * * *" touch outputfile &
sleep 1
ls outputfile
The output was:
root@60173c4f370c:/haha# ./test.sh
Thu Oct 18 18:44:09 UTC 2018
outputfile
root@60173c4f370c:/haha#
So as you can see it immediately ran the command (within one second) even though we were not at the beginning of the minute. It does seem to be touching the file each minute but I have no way of knowing (unlike the previous example) if it is doing so more than once each minute.
It doesn't really matter to me if tasks start at the exact beginning of the minute according to the clock. But it was unexpected behavior.
I did get a command to work when I specified the minute:
root@60173c4f370c:/haha# date
Thu Oct 18 18:46:03 UTC 2018
root@60173c4f370c:/haha# mantra "49 * * * * *" touch hourlyat49 &
...
root@60173c4f370c:/haha# date && ls -l hourlyat49
Thu Oct 18 18:50:16 UTC 2018
-rw-r--r-- 1 root root 0 Oct 18 18:49 hourlyat49
But wait! After another minute passes, the file is touched again, this shouldn't happen for another hour:
Thu Oct 18 18:51:41 UTC 2018
-rw-r--r-- 1 root root 0 Oct 18 18:50 hourlyat49
And again:
root@60173c4f370c:/haha# date && ls -l hourlyat49
Thu Oct 18 18:52:09 UTC 2018
-rw-r--r-- 1 root root 0 Oct 18 18:51 hourlyat49
Seems like there are some issues to be worked out. Hope they can be resolved as there is a real need for a tool like this and it seems like exactly the right approach.
Thanks.