A
A
Azigar2019-08-30 15:44:45
PHP
Azigar, 2019-08-30 15:44:45

Why doesn't CRON + PHP + MEGATOOLS work?

There is a php script:

#!/usr/bin/php
<?php
ini_set('display_errors', 1);	// убираем Notice: 	
error_reporting(E_ERROR | E_WARNING | E_PARSE);
mb_internal_encoding("UTF-8");	// Устанавливаем внутреннюю кодировку символов.

$conf = parse_ini_file('config.ini');							// читаю config.ini
$dump_dir = $conf['dump_dir'];									// папка хранения бэкапов
$mega_dir = $conf['mega_dir'];									// папка хранения бэкапов на облаке MEGA
$root = '/Root';
$date = date("Y-m-d");											// текущая дата

echo "\n";
echo "\nОтправка бэкапов на облако ".date("H:i:s d.m.Y")."\n\n";
///usr/bin/
exec("megamkdir $root$mega_dir/$date");													// создаем на облаке папку для хранение новых бэкапов 
$str = shell_exec("megacopy --local $dump_dir/$date --remote $root$mega_dir/$date");		// синхронизация каталога
echo "$str\n";

echo "\nОтправка бэкапов завершена ".date("H:i:s d.m.Y")."\n\n";
?>

made it executable:
chmod +x ~/send-mega.php
If I run it from the console:
~/send-mega.php
the script works perfectly and poisons files on Mega.
Added it to cron:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
30 14 * * * /home/user/send-mega.php >/home/user/cron .tmp
in the cron.tmp file shows that the script was launched, but does not want to send files.
And there is nothing in the $str variable, because nothing was written to the file.
What could be the problem?
PS
inserted at the beginning of the script wrote: / root and now I don’t understand what to do. I added the full path to the utilities "/usr/bin/" to the script, but it still does not work.
echo getcwd() . "\n";
I wrote the same thing in bash. with full paths. But if from the console, the bash script works. And with krona - does not want, like a php script.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Adamos, 2019-08-30
@Adamos

Insert at the beginning of the script
echo getcwd() . "\n";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question