Running a script longer then 45 seconds causes a mod_fcgid: read data timeout in 45 seconds, this may be plesk specific.
Looking up the error its very common, the usual solution recommended is to editing /etc/httpd/conf.d/fcgid.conf
3600 seconds = 1 hour.
Then restart the server. If you don't have root access to the server you'll need to ask your host to do it or another way is to increase the memory limit with php at the top of the file add:
This solves the problem without needing to edit the fcgid.conf file.