I'm running lots of cron job and once in a while there is a MYSQL has gone away error.
I've now written some code to handle the error, but how do I simulate the error on my localhost so that the code can be tested thoroughly?
Kill a long-running thread.
See: KILL syntax
KILL
The documentation about that error also lists different causes, so you could emulate some of them (eg: change the timeout to be very low, etc).