workflow_script
workflow_script copied to clipboard
Execute scripts from docker container
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.
Is there anything I am missing?
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.
Is there anything else I can try?
@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.txtThen verify using this command:cat /var/www/html/data/TEST.txtShould 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?