I'm looking for a way to know if any account record in the database has been modified today. I know there is a 'modified_at' field in the account record with time/date in it and that is working well via this kind of code:
I was wondering if there was some way I could simply set a "flag" (like a 1 or 0 in a file) when a record is added, changed, or deleted because the above code above is more complex than the problem I'm trying to solve... which is knowing when to reload my backup database for my backup version of EspoCRM.
I know there are some 'hooks' that 'fire" on an update/change/delete to an account record but I don't understand how to use one.
I looked at the docs. Does anyone have a more complete explanation and example?
Code:
curhr=$(date +%-H) if (( $curhr > 05 && $curhr <= 23 )); then #echo "---------it is between 6AM and 11 PM" mycount=$(/usr/local/bin/mysql --login-path=espocrm ancnet1_espo1 -e "SELECT COUNT(*) FROM account WHERE date(CONVERT_TZ(modified_at,'+00:00','-07:00')) = CURRENT_DATE ORDER BY modified_at DESC") else #echo "---------it is not between 6AM and 10PM" mycount=$(/usr/local/bin/mysql --login-path=espocrm ancnet1_espo1 -e "SELECT COUNT(*) FROM account WHERE date(CONVERT_TZ(modified_at,'+00:00','-08:00')) = DATE_SUB(CURRENT_DATE,INTERVAL 1 DAY) ORDER BY modified_at DESC") fi tot1="${mycount//[!0-9]/}" if (( $tot1 <= 0 )) then
I know there are some 'hooks' that 'fire" on an update/change/delete to an account record but I don't understand how to use one.
I looked at the docs. Does anyone have a more complete explanation and example?
Comment