I have a python script that loads up a webpage on a raspberry.
This script MUST run at startup, and then every 15 minutes. In future there will be many of these, maybe 1000 or even more. Currently i am doing this with a cronjob, but the problem with that is that all 1000 raspberries will connect to the webpage at the very same time (plus minus a few seconds given that they take the precise clock from the web) It would be good to execute the command after 15 minutes from the last run, regardless of the time. I like the cronjob solution because i have nothing running in background, so it simply executes does its job and then it's over.
at the other hand, cronjob takes care only of the minutes, and not the seconds, so even if i scatter the 1000 pi's over these 15 minutes I will still end having about 80 simultaneous requests to the webpage every single minute.
Is there a nice solution to this?
You can always add the unix command sleep xx to the cronjob before executing your command.
Example: */15 * * * * (sleep 20; /root/crontabjob.sh)
Now the job will run every 15 minutes and 20 seconds (00:15:20, 00:30:20), 00:45:20 ....)
Cronjob at given interval