i don’t know whether its the correct category, but following problem:
i am doing some mysqldump database backups via a .php file which is running by a cronjob. The mysqldumped backups are writte to my Cloud storage. To see this files i want to add the occ command, to scan the SQL backup folder after completing the backup. You understand?
Therefor, i need to execute the occ command in my php file. Following command does work in SSH:
php7.1-cli /homepages/33/d697614970/htdocs/clickandbuilds/nextCloud/occ files:scan --path=Oernifly/files/Backup_SQL
So, it would be so easy, if i have to add the command with a exec() in to my .php file. But this does not work.
echo exec( 'php7.1-cli /homepages/33/d697614970/htdocs/clickandbuilds/nextCloud/occ files:scan --path=Oernifly/files/Backup_SQL' );
i tried so many different ways to describe the command. exec(), system(), shell_exec()
The command does not give a respond. Blank page…
It is not due to missing permissions. The php files runs the same as the SSH.
Anybody an idea for that? I want to rescan my god dammed folder after the backup. It can’t be that hard… ?! wtf.
I don’t now why it should be necessary to force a file system scan, because my experience is,
that new files are usually displayed instantly if you’re accessing a folder. Nevertheless if you
want to execute a program it is
always good to use an absolute path to the PHP cli program.
check the access rights of the PHP cli program because it is usually executed with
the rights of the user under which the web server is running. Try to execute e.g. a
"/<path-to-cli>/php7.1-cli --version" first.
check the access right of the path to the Nextcloud root. The user which is used to
execute the command, ususally the user under which the web server is running,
need to be able to find and access the occ command.
Because the files should part of the automatic sync of my Desktop PC (for having an offline backup and an online backup if the server crashes) - and this is only possible if the file are discovered.
So i entered the absolute path for the PHP CLI. No reaction.
The path/command is: “/usr/bin/php7.1-cli -v” If i run this in SSH, i get my informations. If i execute this in my PHP file nothing happens. So the problem is, that i can’t access php7.1-cli by PHP right? How to fix this? I am on a webhoster and can’t access the file my myself. And why i can access the php version via the same user in SSH?
But i checked with following command
$username = posix_getpwuid(posix_geteuid())['name']; which user PHP i running. its the same as the SSH user.
- How to check that?
Not seeing a reply doesn’t automatically mean that a program is not being executed.
You should try to redirect the exec output to a variable as described here:
Okay i did as mentioned. Following output: php7.1-cli: not found
I think the hoster didn’t gave me the permissions to access the php executable or smth.
Can i install php-cli on my own? Or is the user for executing php files a different as the SSH user?
i don’t understand anything now… What can i do?
Sorry, this is definitely not a Nextcloud problem and cannot be answered in general because all server environments are different. Best would be to ask your hoster to answer these question.
Hehe, i know - but they never answer to this kind of replys
oh yeah finally got it.
I don’t understand it anyway. But php7.1-cli doesen’t exist and php7.3-cli exists and is usable. Why SSH can run php7.1-cli I DONT KNOW.
I listed with following script my accesscable folder from php:
exec(‘ls /* 2>&1’, $output);
then i entered the next path i believe the php file could be in it
exec('ls /usr/* 2>&1', $output);
until i reached a working php folder. great. Thanks for your help.