Estimated reading time: 0 minutes, 18 seconds
Problem: Server returns the error "Mysql server has gone away" when running a large set of queries (specially as a Cronjob).
Solution: Simply copy/paste the following lines in beginning of your php file.
ini_set('mysql.connect_timeout', 300);
ini_set('default_socket_timeout', 300);
Reason: The mysql.connect_timeout option is the reason for this.