You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi everyone,
I am running NextCloud within docker (based on “with-nginx-proxy/mariadb/fpm”) which works very well. But I can not get Flow working with external scripts.
I want to run a script when a defined file is opened. I have installed the “external script” app and configured a flow with:
“File accessed” and file name is “nextcloud_flow_test.txt” run script at “/var/www/html/config/test.sh”.
But the script is not executed when accessing the file from my NextCloud Webinterface.
The script itself is accessable from the docker container. I started it via an interactive shell from the container (docker exec -it nextcloud bash). Currently the script just inserts the current date to a text file (date >> test.txt) which works fine when executed manually.
Not running on docker, and not having an idea why it should not work in principle about of the usual (user, permissions).
A script is executed from a background job (make they are executed). Set the loglevel to 1 and watch the audit.log (also in data dir), to first verify whether the flow is actually activated and executed.
I checked the logs and can find entries of workflow_script:
Info workflow_script executing sh -c '/var/www/html/config/test.sh' >/dev/null &
with the follwoing details:
{"reqId":"WaQmOM0mhJTg921r8qGr","level":1,"time":"2025-10-07T18:29:05+00:00","remoteAddr":"","user":"--","app":"workflow_script","method":"","url":"--","message":"executing sh -c '/var/www/html/config/test.sh' >/dev/null &","userAgent":"--","version":"31.0.9.1","data":{"app":"workflow_script"},"id":"68e55d1eb268e"}
In the web view my nextcloud instances states cron is being used and the last job ran seconds ago.
I changed the script to write execute date >> /test.txt in case the script is executed in some sub directory and the resulting file is stored anywhere. But still I can not find the file test.txt. Either within the docker container of the nextcloud application, the docker container of the cron job or also on the host machine.
@Mailblocker
'date >> /test.txt' means it's gonna go into very root of filesystem - probably don't have rights there.
Try this sample script: touch /var/www/html/data/TEST.txt chmod 777 /var/www/html/data/TEST.txt chown www-data:www-data /var/www/html/data/TEST.txt echo "HELLO WORLD" > /var/www/html/data/TEST.txt
Then verify using this command: cat /var/www/html/data/TEST.txt
Should output HELLO WORLD obviously.
@Mailblocker 'date >> /test.txt' means it's gonna go into very root of filesystem - probably don't have rights there. Try this sample script: touch /var/www/html/data/TEST.txt chmod 777 /var/www/html/data/TEST.txt chown www-data:www-data /var/www/html/data/TEST.txt echo "HELLO WORLD" > /var/www/html/data/TEST.txt Then verify using this command: cat /var/www/html/data/TEST.txt Should output HELLO WORLD obviously.
Thanks for the input! Unfortunately no change of result.
I created the script as you mentioned and I got this file now in my docker container available: -rwxrwxrwx 1 www-data www-data 37 Oct 21 19:15 TEST.txt
It is accessable as expected but I needed to change its contents to get an actual timestamp when the script was executed the last time: echo "date >> /var/www/html/data/test2.txt" > /var/www/html/data/TEST.txt
It worked to execute this script from the container shell itself. But in this case the file test2.txt is created with root ownership. So I deleted it and tried to execute the script via flow with the same result as mentioned my initial post:
The nextcloud log states a script has been executed. But no file test2.txt is created within the docker volume.
Can anyone reproduce this error? I am a little bit stuck here, not sure where the problem is located. Is it me or is this a problem in the combination docker + workflow script?
You may want to check if you are in the right container. I have a compose where CRON service has a separate container beside APP. The script have to be accessible in the CRON container (not APP).
I missed that for hours...
As you see in the Log /dev/null is used. If your script fails you won't see it in the logs. Better trigger your workflow and than php -f /your/path/cron.php with www-data user manually (in the right container). Add extra logging like seen below.
If your script takes longer than cron.php it gets killed when the php process ends e.g. a curl (even though subshell is spawned with &. That ws the hardest lesson...
SonI end up wuth a robust solution for point 2 and 3. In the run_script App I defined the command as follows:
Activity
blizzz commentedon Oct 6, 2025
Not running on docker, and not having an idea why it should not work in principle about of the usual (user, permissions).
A script is executed from a background job (make they are executed). Set the loglevel to 1 and watch the audit.log (also in data dir), to first verify whether the flow is actually activated and executed.
Mailblocker commentedon Oct 7, 2025
I checked the logs and can find entries of workflow_script:
Info workflow_script executing sh -c '/var/www/html/config/test.sh' >/dev/null &with the follwoing details:
{"reqId":"WaQmOM0mhJTg921r8qGr","level":1,"time":"2025-10-07T18:29:05+00:00","remoteAddr":"","user":"--","app":"workflow_script","method":"","url":"--","message":"executing sh -c '/var/www/html/config/test.sh' >/dev/null &","userAgent":"--","version":"31.0.9.1","data":{"app":"workflow_script"},"id":"68e55d1eb268e"}In the web view my nextcloud instances states
cronis being used and the last job ran seconds ago.I changed the script to write execute
date >> /test.txtin case the script is executed in some sub directory and the resulting file is stored anywhere. But still I can not find the file test.txt. Either within the docker container of the nextcloud application, the docker container of the cron job or also on the host machine.Mailblocker commentedon Oct 17, 2025
Is there anything else I can try?
executed commentedon Oct 20, 2025
@Mailblocker
'date >> /test.txt' means it's gonna go into very root of filesystem - probably don't have rights there.
Try this sample script:
touch /var/www/html/data/TEST.txt chmod 777 /var/www/html/data/TEST.txt chown www-data:www-data /var/www/html/data/TEST.txt echo "HELLO WORLD" > /var/www/html/data/TEST.txtThen verify using this command:
cat /var/www/html/data/TEST.txtShould output HELLO WORLD obviously.
Mailblocker commentedon Oct 21, 2025
Thanks for the input! Unfortunately no change of result.
I created the script as you mentioned and I got this file now in my docker container available:
-rwxrwxrwx 1 www-data www-data 37 Oct 21 19:15 TEST.txtIt is accessable as expected but I needed to change its contents to get an actual timestamp when the script was executed the last time:
echo "date >> /var/www/html/data/test2.txt" > /var/www/html/data/TEST.txtIt worked to execute this script from the container shell itself. But in this case the file
test2.txtis created with root ownership. So I deleted it and tried to execute the script via flow with the same result as mentioned my initial post:The nextcloud log states a script has been executed. But no file test2.txt is created within the docker volume.
Mailblocker commentedon Oct 30, 2025
Can anyone reproduce this error? I am a little bit stuck here, not sure where the problem is located. Is it me or is this a problem in the combination docker + workflow script?
Pitastic commentedon Jul 12, 2026
I learned some details in my long debug Session.
I missed that for hours...
As you see in the Log
/dev/nullis used. If your script fails you won't see it in the logs. Better trigger your workflow and thanphp -f /your/path/cron.phpwith www-data user manually (in the right container). Add extra logging like seen below.If your script takes longer than
cron.phpit gets killed when the php process ends e.g. acurl(even though subshell is spawned with&. That ws the hardest lesson...SonI end up wuth a robust solution for point 2 and 3. In the run_script App I defined the command as follows:
setsid /bin/bash /test.sh %f </dev/null >>/tmp/cron.log 2>&1 &