D
D
Diversia2019-04-03 11:07:55
linux
Diversia, 2019-04-03 11:07:55

What is the best way to execute php script in cron?

Please tell me how, from the point of view of saving server resources, it is better to execute a php script: via wget or with the command:
/opt/plesk/php/7.0/bin/php -c /var/www/vhosts/system/site/etc/php.ini -f /var/www/vhosts/site/httpdocs/file.php

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yuri, 2019-04-03
@riky

Yes, the mechanism is provided. I just thought maybe krone has some option.

Diversia , there is no option, but they do it with flock
, that is, they write
/usr/bin/flock -w 600 /var/tmp/myscript.lock /root/myscript.sh in the
cron https://pingtool.org/en/using- flock-to-ensure-only...

M
metajiji, 2019-04-03
@metajiji

100% via cli +, as already noted, use flovk, which will save you from re-running the script if the previous one has not completed its work.
Why is cli better? Because the script may run longer than, for example, the configured timeout on the web server. In the cli, the script is guaranteed to work, and don't forget to run it via sudo, for example:
sudo -u apache php ... script.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question