When all the above methods are executed on Linux, a pit will appear and multiple processes will appear. Because if there is a delay, after more than 60 seconds, the second scheduled task will start. Multiple processes will appear. process. The solution is to add file lock /usr/bin/flock
Scheduled by crontab every minute, each time it is invoked, the loop is executed 120 times with an interval of 0.5 seconds
Since
crontab
the minimum unit is minutes, you can only write your own program to execute it. Give an example of shell + python:or python + shell:
I don’t have linux, so I haven’t tested it myself. That’s probably the idea
Try it with
watch
watch -n 0.5 date
It’s not convenient to test on a Windows machine, maybe something like this
Use usleep to sleep for half a second for one minute, just combine it with cron
Not found. It can only reach the level of minutes, not even seconds.
Let’s talk about your usage scenarios
The shortest definition of crontab can only be up to minutes, which can only be completed with the script sleep
When all the above methods are executed on Linux, a pit will appear and multiple processes will appear.
Because if there is a delay, after more than 60 seconds, the second scheduled task will start. Multiple processes will appear. process.
The solution is to add file lock /usr/bin/flock