How to use cronjob to execute periodical MySQL queries?

D.T.'s Blog

For my new project, I needed to aggregate user view counts periodically. After i googling around, i figured using cronjob probably was the most popular way of doing it. So i wrote my sql queries to a file and schedule a cronjob to execute the script every 30 minutes. Here are the detail steps of how i did it:

1.Write sql queries to a text file named recurring-job.sql. Put it under your user’s home directory /home/[user].

2.Edit cronjob by issuing following commands.

3. Add a new line into cronjob configuration. This configuration will execute the sql script every 30 minutes.

4. Hit ctrl-X and type “Yes” to save and exit.

That’s it! But how do I make sure the job actually run?

Happy Coding!

View original post

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s