0

I'm writing a utility for work using forms, then submitting the supplied information into a database with php. The work this intended for is to be performed every thirty days. I need to find a way to automatically check the database and be sure each table in this database has had an entry within the last 30 days or email me if not. Any help you all might give would be greatly appreciated.

3
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by uktena
0

If you want an automatic check, use CRON JOBS - see your host for this as they don't always supply this facility. Else, get a script to email you every time the db is updated. If it's just a simple mail, the php mail() function should be fine.

If the db is updated a number of times every month, the emails will become tedious, so I would use CRON JOBS in this case. You'll still need to write a script for the cron job. Something like:

[your php script]
1. check the tables for the latest entry/update
2. use the php date function and the mysql date_format function to just check the numerical month or something more sophisticated (e.g. last 30 days)
3. if no records are returned for a table, note it.
4. collate the info and mail it via mail().

If you produce a script I'll have a look at it and advise further.

0

yea, definately a cron job would be your best bet. If youre hosting on a cPanel server, you can do this without going to the command line. If not, and you'll either need to get your host to set up the job for you, or if you have ssh, you can create the cron job yourself.

0

Still stuck here. I understand how to make most of this work, and yes thankfully I do have Cron. The part that's getting me is this, each of my tables have a field for timestamp. I can search and pull the most recently timestamped record. However, finding a way to have my script compare this timestamp with the current time and date is the problem.

0

Looks as though I got it working thanks for your help. The whole thing seems to be working perfectly, so far.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.