I have a file:
-rw-r--r-- 1 michal michal 1679 Apr 24 06:55 acx.php
The owner file acx.php
is user michal
, so I create cron using:
sudo crontab -u michal -e
My cron:
*/10 * * * * php /var/www/html/cron/exchange/acx.php
In log cron I see:
Apr 25 04:10:01 savecoin CRON[9722]: (michal) CMD (php /var/www/html/cron/exchange/acx.php)
I change the permission file acx.php
on 777
, but it did not help. When I run the cron manually, the data correctly saves to the database. I do not know what else I can change so that cron can write data to the database
I use php7.2, apache2 http server and MySQL database.
/usr/bin/php
instead of justphp
in the cron ? – ponsfrilus Apr 25 '18 at 08:42sudo crontab -e
)? You can redirect the output to a log file, maybe there will find some clue (*/10 * * * * php /var/www/html/cron/exchange/acx.php >> /path-to/log 2>&1
). – pa4080 Apr 25 '18 at 08:49php
to/usr/bin/php
it did not help. @pa4080 in new log file I see error:PHP Warning: include_once(../db.php): failed to open stream: No such file or directory in /var/www/html/cron/exchange/acx.php on line 2 PHP Warning: include_once(): Failed opening '../db.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/cron/exchange/acx.php on line 2 PHP Fatal error: Class 'Database' not found in /var/www/html/cron/exchange/acx.php on line 9
, when I run file acx.php using the commandphp acx.php
then the script correctly save data to the database – michal Apr 25 '18 at 09:14*/10 * * * * cd /var/www/html/cron/exchange/ && php acx.php
– pa4080 Apr 25 '18 at 09:16