PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

PHPMaster.com: How I Faked Scheduled Database Dumps Without Cron

Note: This article was originally published at PHPDeveloper on 28 March 2012.
PHPDeveloper

On PHPMaster.com today there's a new tutorial about a way to simulate cron jobs to dump the contents of a database with a simple script that fires off based on the last login time of a certain user (using the MySqlDumper tool).

My program required a accurate username and password to present its features to the user, and there is one predefined user who is idle most of the time and does just two things: wipe stale database entries and restore the database when needed. According to my login procedure, each time a user successfully logs in the system automatically updates the last login date to the current date. And that was the hint I desperately needed.

A brief snippet of code is included showing how he implemented the solution - MySQL commands and parameters defined in constants and called only when the last login time is less than "today".