cool
cool

Reputation: 788

The host don't allow events on MySQL, what is the best alternative

I need events for MySQL database, But I realize that I can't have event for the host's level I bought. The only solution that I come up with is: 1- create a php page with a single button in it. 2- put the event codes into this page 3- put this page in a password protected folder 4- and every hour, open the page and hit the button. Not a good idea? I know. So, what is the best alternative?

Upvotes: 1

Views: 1376

Answers (2)

Venkat.R
Venkat.R

Reputation: 7736

As Jim in the comment. Try to use Cron Job and call your PHP Script for every hour is my alternative answer.

#!/usr/bin/env php
<?php
# This file would be say, '/usr/local/bin/run.php'
// code
echo "I'm CRON Script"

Add a Cron Job Command Structure:

Minutes [0-59]
|   Hours [0-23]
|   |   Days [1-31]
|   |   |   Months [1-12]
|   |   |   |   Days of the Week [Numeric, 0-6]
|   |   |   |   |
*   *   *   *   * home/path/to/command/the_command.sh

Command Example:

* 1 * * * php-path -f php-script-path &> /dev/null
* 1 * * * /usr/bin/php -f /usr/local/bin/run.php &> /dev/null

Add Permission through CHMOD command.

chmod +x /usr/local/bin/run.php

Reference:
How to create cron job using PHP?
http://code.tutsplus.com/tutorials/managing-cron-jobs-with-php--net-19428

Upvotes: 1

Venkat.R
Venkat.R

Reputation: 7736

Check the current process list by below command / enable event scheduler.

SHOW PROCESSLIST;
or
SET GLOBAL event_scheduler = ON;

enter image description here

Refer the Below URLs
https://dev.mysql.com/doc/refman/5.7/en/events-overview.html
http://www.sitepoint.com/how-to-create-mysql-events/
http://www.mysqltutorial.org/mysql-triggers/working-mysql-scheduled-event/

Upvotes: 0

Related Questions