You'd need a shell script named optimize.sh; I coded mine from scratch; such scripts don't exist as any standard; you'd have to customize the hell out of an input string to MySQL lol.
On mine, i specify what tables i want optimized, and in what databases; then have it execute it at the beginning of my backup batch.