I have this code related with the download, unzip, search and upload to a AWS S3. 
I have a function to download, another to unzip, another to make the searches and another function to upload the found files; to finally call all this functions into one function. 
The problem it's that at some point (specifically in the last function) the execution gets an error. 
The code has 1684 lines of code, and could take even 4 hours to execute. 
If an error is found in a function, the try/catches guarantee the final return. 
I've tried to call every function sequentially and they work. 
If trying to call all the functions, except the last one it still works. 
If trying to call the last function (the upload to S3), it works. 
I believe it could be related with the RAM 
Trust me, it's huge
Basically, my problem was solved through the creation of a ".sh" format script that calls all the functions sequentially.
Two functional functions when called together creates an error