Increase limit of open files

Discussions about the usage of KeyHelp.
Post Reply
PuntonetSvb
Posts: 36
Joined: Thu 7. Apr 2022, 19:16

Increase limit of open files

Post by PuntonetSvb »

I have a php program that joins thousands of pdf files into one just to send it to the printer, but the moment I go beyond 1024 I get the error:


I have followed all the tutorials I have found, I have modified the /proc/sys/fs/file-max file

I have tried:
sysctl -w fs.file-max=600000
but I'm still the same as I was, as soon as I go beyond 1024 open files the program stops and the error appears

AH01071: Got error 'PHP message: PHP Warning: fopen(./fras/1017.pdf): Failed to open stream: Too many open files in
User avatar
24unix
Posts: 1995
Joined: Sun 21. Jun 2020, 17:16
Location: Kollmar
Contact:

Re: Increase limit of open files

Post by 24unix »

Why don't you just close the files after concating with the main file?
Cheers Micha
--
If you can see it and it's there - it's real.
If you can't see it and it's there - it's transparent.
If you can see it and it's not there - it's virtual.
If you can't see it and it's not there - it's gone.
User avatar
Tobi
Community Moderator
Posts: 3166
Joined: Thu 5. Jan 2017, 13:24

Re: Increase limit of open files

Post by Tobi »

My suggestion:

Combine the first 1000 files into one file.
Then the next 1000 files.
And so on.

After the these combinations, you can combine the 1000-combine-files into one extreme large file.
Gruß,
Tobi


-----------------------------
wewoco.de
Das Forum für Reseller, Digital-Agenturen, Bildschirmarbeiter und Mäuseschubser
User avatar
Jolinar
Community Moderator
Posts: 3964
Joined: Sat 30. Jan 2016, 07:11
Location: Weimar (Thüringen)
Contact:

Re: Increase limit of open files

Post by Jolinar »

Consider Alternatives:

- Command-line tools: Tools like pdftk offer command-line PDF merging options that might be more efficient for large datasets.
- Third-party libraries: Explore dedicated PDF manipulation libraries like setasign/fpdi for PHP that offer optimized functionalities for merging PDFs.
Wenn jemand inkompetent ist, dann kann er nicht wissen, daß er inkompetent ist. (David Dunning)

Data Collector für Community Support
___
Ich verwende zwei verschiedene Schriftfarben in meinen Beiträgen /
I use two different font colors in my posts:
  • In dieser Farbe schreibe ich als Moderator und gebe moderative Hinweise oder begründe moderative Eingriffe /
    In this color, I write as a moderator and provide moderative guidance or justify moderative interventions
  • In dieser Farbe schreibe ich als Community Mitglied und teile meine private Meinung und persönlichen Ansichten mit /
    In this color, I write as a community member and share my personal opinions and views
PuntonetSvb
Posts: 36
Joined: Thu 7. Apr 2022, 19:16

Re: Increase limit of open files

Post by PuntonetSvb »

Jolinar wrote: Tue 21. May 2024, 14:52 Consider Alternatives:

- Command-line tools: Tools like pdftk offer command-line PDF merging options that might be more efficient for large datasets.
- Third-party libraries: Explore dedicated PDF manipulation libraries like setasign/fpdi for PHP that offer optimized functionalities for merging PDFs.
I use this library, but I didn't find an option to close the file after importing it

// set the source file
$pdf->setSourceFile($fichero);
// import page 1
$tplId = $pdf->importPage(1);

No matter how much I searched, I couldn't find the option to close the file after importing it.
User avatar
BasHeijermans
KeyHelp Translator
Posts: 170
Joined: Mon 20. Jun 2022, 12:01
Location: Heppen Belgium
Contact:

Re: Increase limit of open files

Post by BasHeijermans »

Openfile -> append to main-file -> close file -> next pdf.

Looks to me you keep them open all the time.

Why don't you do the above? Then it doesn't matter how many files you have.
Greetings Bas.

Ik heb KeyHelp naar het Nederlands vertaald, contacteer me als er translatie fouten zijn.
(I have translated KeyHelp into Dutch, contact me if there are translation errors.)
Next version 24 of KeyHelp 100% translated.
Post Reply