Make a lock of a cron


to see if someone gives me a hand, I have a cron that generates a feed of products in 26 languages, and it starts to happen that sometimes gives timeout I have happened to divide the file into 3 instead of having script.php have script1.php script2.php script3.php and launch the cron to script 1 but that the 2 does not start until the end of 1 so they do not get crushed, it would be something like this

51 01 * * * curl -IH 'Host:' -H 'SSL-ON: on'
51 01 * * * curl -IH 'Host:' -H 'SSL-ON: on'
51 01 * * * curl -IH 'Host:' -H 'SSL-ON: on'

Another option is to leave a considerable amount of time between them, but I do not know if it's the best option, does anyone know about it?

asked by Yus 11.07.2018 в 15:13

2 answers


I can think of this option:

51 01 * * * curl --max-time 1200 -IH 'Host:' -H 'SSL-ON: on'

Where the option --max-time defines in seconds the time that has to pass for the timeout to occur. I have put in the example 1200 seconds (20 minutes), but you can adjust it to what you consider appropriate

answered by 11.07.2018 в 15:35

and what if you put everything together in a single megacommand with & ?

51 01 * * * curl -IH 'Host:' -H 'SSL-ON: on' & curl -IH 'Host:' -H 'SSL-ON: on' & curl -IH 'Host:' -H 'SSL-ON: on'

so everything would be executed sequentially. Or if you want something more ordered, create a sheel script with the commands, say :

curl -IH 'Host:' -H 'SSL-ON: on'
curl -IH 'Host:' -H 'SSL-ON: on'
curl -IH 'Host:' -H 'SSL-ON: on'

then you give execution permission with chmod +x and add to your crontab with:

51 01 * * * /larutadondeeste/
answered by 11.07.2018 в 17:41