L
L
leni_m2018-05-16 19:12:33
PHP
leni_m, 2018-05-16 19:12:33

How to execute php script via cron?

The rights to execute the script are worth it.
The server is ubuntu.
I open crontab through the console crontab -e,
then I write to run the script every 5 minutes

*/5 * * * * /usr/bin/php /var/site.ru/script.php >/dev/null 2>&1

The php script itself to delete files in one of the folders. And if you open it from the browser, the files are deleted. And cron doesn't want to do something.
I went into var/log/syslog and there are entries every 5 minutes, but I don’t understand how to understand what the error is.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yan-s, 2018-05-16
@leni_m

Well, first try to run the script manually from the console in the same way as you try in the cron, that is, by entering the command /usr/bin/php /var/site.ru/script.phpand see what it will answer.

B
BeHePCo, 2021-12-25
@BeHePCo

I use Vesta CP
Command:
/usr/bin/php /usr/bin/php /home/admin/web/sat/public_html/cronjob/check-nocredited.php
gives an error:
/usr/bin$ /usr/bin/php / usr/bin/php /home/admin/web/sat/public_html/cronjob/check-nocredited.php
PHP Warning: PHP Startup: Unable to load dynamic library 'php_pdo_sqlsrv_74_nts.so' (tried: /usr/lib64/php/modules /php_pdo_sqlsrv_74_nts.so (/usr/lib64/php/modules/php_pdo_sqlsrv_74_nts.so: undefined symbol: php_pdo_register_driver), /usr/lib64/php/modules/php_pdo_sqlsrv_74_nts.so.so (/usr/lib64/php/modules/php_pdo_sqlsrv_74. so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning: Module 'sqlsrv' already loaded in Unknown on line 0
PHP Parse error: syntax error, unexpected '&', expecting end of file in /usr/bin/php on line 3341
the php file itself works.
What could be the problem?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question