wp_update_attachment_metadata breaks after 10 files

It seems like it is a execution time problem. So I decreased it on the server & am doing the year folder now hardcoded one by one, write the executed images in a json file and only insert those who are not in there… and hope for the best.