Q: Is it okay to set cronjob run script every minute or will it cause overload?
Reason why i want to run it every minute is:
Public script:
* Client adds (for example:) advertisment
* Script inserts data in mysql database (when = time + 2hrs, activated = 0, …)
Cronjob runs:
* Script checks mysql database, WHERE time is lower than "NOW", activated = 0 and takes that info, inserts it to another table, sets activated = 1 when it is inserted.. (activated = 1 happens in the first table (where Public script puts info))
So if this script runs every minute will is cause overload?
If Yes:
Q2 Is there other options you could suggest (about chaning how the script works)?
Thank you!
Every minute might be excessive, but it won’t overload the computer. All you’re performing is 1
SELECTand a fewINSERTs. That should take a few seconds max.One design change you could make, though, is that generally it doesn’t make sense to copy data between tables in a relational database. You probably want to just reference the data with a foreign key, and use
JOINstatements to access it with other information. In this case you wouldn’t copy anything in your cron job; you’d just insert a foreign key.