Clarity on the crontab settings for the preview generator app

wget with pull request about iPreviews merged :slight_smile:

By the way: integrity check is removed now!?

Is it @MichaIng? I hadn’t noticed.
@rullzer @nickvergessen

nothing more to do than loading the app, renameing and enableing?
or run pre-gen.
could you please give a quick summary like:

  1. wget
  2. enable “new” gal.-app
  3. run pre gen

I did:

  1. download and enable gallery and pre-gen - apps from git
  2. sudo -u www-data /var/www/nextcloud php occ preview-generate-all
  3. wait
  4. sudo crontab -u www-data -e and paste

@hourly php -f /var/www/nextcloud/occ preview:pre-generate > /home/NextcloudUser/preview.log

does it fit?
thx in advance, carsten

Hi there,
1st of all, thanks for your work.
I’m using the occ preview generator command.
I’ve also “updagre” the gallery app directly from github, so I’m actually using the new shared preview infrasctructure (folder owncloud/data/appdata_<identificator>/preview).

BUT I’m seeing that when I get a big preview of a photo the gallery app STILL generate a new file.
I think the problem that te “occ preview:(generate-all|pre-generate)” command is generating the thumbnails with the following names:

[root@ciberterminal 5382]# ll
total 812
-rw-r--r-- 1 apache apache 136172 Jan  4 21:05 1024-1365.png
-rw-r--r-- 1 apache apache   3630 Jan  4 21:05 128-171.png
-rw-r--r-- 1 apache apache 241146 Jan  4 21:05 1440-1920-max.png
-rw-r--r-- 1 apache apache 241152 Jan 13 10:02 1440-1920.png         <= this is a new one generated by
-rw-r--r-- 1 apache apache   6639 Jan  4 21:05 192-256.png
-rw-r--r-- 1 apache apache    879 Jan  4 21:05 24-32.png
-rw-r--r-- 1 apache apache  11225 Jan  4 21:05 256-341.png
-rw-r--r-- 1 apache apache    906 Jan  4 21:05 32-32-crop.png
-rw-r--r-- 1 apache apache   1002 Jan  4 21:05 32-43.png
-rw-r--r-- 1 apache apache  24524 Jan  4 21:05 384-512.png
-rw-r--r-- 1 apache apache   1272 Jan  4 21:05 48-64.png
-rw-r--r-- 1 apache apache  42710 Jan  4 21:05 512-683.png
-rw-r--r-- 1 apache apache   1391 Jan  4 21:05 64-64-crop.png
-rw-r--r-- 1 apache apache   1620 Jan  4 21:05 64-85.png
-rw-r--r-- 1 apache apache  85482 Jan  4 21:05 768-1024.png
-rw-r--r-- 1 apache apache   2504 Jan  4 21:05 96-128.png

So is is not using “1440-1920-max.png” pre-generated file, it generates a new “1440-1920.png” which is the same as the pre-generated.

My config.php settings include:

      'preview_max_x' => 1920,
      'preview_max_y' => 1920,

I’ll try to make a trick (symlink) to see if it works and gallery doesn’t generate new thumbs.


I’ve symlink’ed all the “max” files to the name gallery app uses and it works:

cd /owncloud/data/appdata_<instanceid>/preview
for i in $(find . -name "*-max.png") ; do [[ ! -f $(dirname $i)/$(basename ${i} -max.png).png ]] && ln -s $(dirname `readlink -e ${i}`)/$(basename $i) $(dirname `readlink -e $i`)/$(basename ${i} -max.png).png ; done

That would be a bad idea until the bugs are not fixed @rullzer!
That could freeze your box :frowning:

The app does not log the filename in case of error, cannot generate a preview of mp3 without cover and stucks on certain PDF files.

Bug list (for the moment, i’m still debugging)

I can confirm this problem with the occ preview:pre-generate command with an MP3 file w/o cover. In my case it is one file of a series of single channel frequency tone files from

Not the only one!

In the worst case your box is getting frozen.

I would suggest to downgrade it to beta state until the bugs are not fixed.

Yeah I know the app is not perfect. At the moment I simply don’t have the time/priority to work on this in my free time.

But pull requests are welcome


I’m getting following error on nextcloud box after preview:generate-all and preview: pre-generate

ERROR: object ‘/usr/lib/arm-linux-gnueabihf/libarmme
.so’ from /etc/ cannot be preloaded (cannot op
n shared object file): ignored.
The process control (PCNTL) extensions are required in case
you want to interrupt long running commands - see http://ph
There are no commands defined in the “preview” namespace.

I appreciate if someone could help…

Hmm, app is definitely enabled successfully? Did you try to remove it and redownload/enable?

I reenabled the app and rebooted the server. Still the same error… Someone else opened an issue with the same error on different commands on nextcloud-snap github…

Yes that’s true, I also did see PCNTL errors on two other topics in combination with nc box/snap.

What in case we copy files into a nextcloud user’s folder directly on the file system - is it succicient to run files:scan to get them added to the mentioned list?

What happens if files are deleted directly from the system? Will the preview-files still be stored on the disk?

in my config.php:
‘preview_max_x’ => 256,
‘preview_max_y’ => 256,
‘preview_max_scale_factor’ => 1,

in Generate.php and PreGenerate.php:

$maxW = (int)$this->config->getSystemValue(‘preview_max_x’, 2048);
$maxH = (int)$this->config->getSystemValue(‘preview_max_y’, 2048);

$s = 256;
while ($s <= $maxW || $s <= $maxH) {
$this->sizes[‘square’][] = $s;
$s *= 2;

$w = 256;
while ($w <= $maxW) {
$this->sizes[‘width’][] = $w;
$w *= 2;

$h = 256;
while ($h <= $maxH) {
$this->sizes[‘height’][] = $h;
$h *= 2;

As a result, in my /preview catalog only 2 files (for each *.jpg) are generated instead of ten or more files (170-170crop.png and 256-170max.png). This greatly accelerated my server based on Pi.
But if I manualy delete files from Linus file system, NC don’t understand this. What method may be used for cleaning database records?

1 Like

Since the generation of images takes time on a slower board like a RP3 and the preview command is in a cron job, what happens if I set the cron for every hour and the cron runs the job again while the previous job has not completed? Will it detect that the job is already running and exit gracefully?

Thank you

@rullzer what say you?


You can start the cronjob like that to find it out:

*/20 * * * * php /var/www/nextcloud/occ preview:pre-generate >> /var/ncdata/preview.log

Sorry for digging this thread up, but does anyone here have experience with hosted systems i.e. from
My nextcloud instance is running on one of their hosted packages and my suspicion ist that there is no way I can run the cronjobs needed there without terminal access?

sorry, complete noob here :frowning: