Help with the External scripts App

I want to reduce the image quality of every image, but nothing happens.

I can use the command in the bash, the file is there but the size stays the same.

Is there a logfile?

What’s wrong with the config?


I’ve personally not using the app, but I would like to mention the following points which might help you solving your issue:

  • Instead of directly executing a command you could use a bash script as a wrapper for debug purposes. Alternatively you can append an output redirection to the command to be executed, like >> /tmp/name-of-the trace-file.log to catch its screen writing.

  • If you want to trace what a bash script is doing, you could insert the following lines at the beginning of the script:

    exec 2>/tmp/name-of-the trace-file.log
    set -x
  • The command/script is most likely executed with the execution rights of the user under which the web server is running, e.g. www-data or wwwrun. So you have to make sure that it can execute the command and is allowed to write to the desired file/directory etc.

  • You’re providing a file name without a path, it might be possible to you have to provide a file path too to allow the script to find the file.

  • Nextcloud relies on file information stored in its database, so you most likely have to make sure that the information is updated if the file is replaced on the file layer. See occ files:scan --path=PATH for further information.

Just my 2ct …

Hi @j-ed,
But it’s not working.
I trigger a shellscript which writes the current time to a logfile on every upload greater then 1 MB.
I can trigger the shellscript in the bash with

sudo -u www-data /tmp/

and its working.

But after an upload > 1 MB nothing happend.

Any other ideas?

Thanks and regards!

As written in the description of the app, the execution of the rules is not controlled by the app but Nextcloud. This means it will only be executed if the default Nextcloud cron command is executed (e.g. /usr/bin/php -f /var/www/htdocs/nextcloud/cron.php).
I just did some quick tests and it worked as expected.

Hi, I’m new to the forum, I would like to achieve something slightly different:

I have a rule in Workflow -> Automated tagging that tags certain files by looking to specific filenames
i would like to move/copy all the tagged files to a different directory, any suggestion?


@byographic Just do it so. What do you want me to tell you?

Any help, how to set up the script, because I’ve tried something like cp /files/documents…
But is not working

Thanks. It’s working now! :slight_smile:

sudo -u www-data php -f /var/www/nextcloud/cron.php
was the solution.

/usr/bin/jpegoptim -m90 /var/nc_data"$1"
/usr/bin/php /var/www/nextcloud/occ files:scan --path="$1"

Works fine for me!

1 Like

@byographic It should work fine, as long as you make sure that the system cron job is executed as mentioned before. This is e.g. a working example which I used to move a tagged image file to a separate folder:

mv -v /var/www/htdocs/nextcloud/data/%n /var/www/htdocs/nextcloud/data/%o/files/Pictures/2019/ >> /tmp/nc-exec-external-script.log
1 Like

How to auto compress videos:

Dateiname entspricht: /.*.mp4$/i
Run script: /tmp/ %n %o

ffmpeg -i /var/nc_data"$1" -vf scale=-2:720:flags=lanczos /var/nc_data"$1"_comp_720.mp4
/usr/bin/php /var/www/nextcloud/occ files:scan --path="$1"

1 Like