I need some help to improve the idea/implementation.Scenario is local mini ISP. users accounts are stored in freeradius/mysql. The task is to send user email who have consumed 80% of there assigned quota.I have configured bash script scheduled run after every 1 hour, that checks for users in mysql table who have downloaded 75% of quota assigned to them and then ADD there username and email to a file /tmp/overquotauser.txt like thisuser1 user1email@domain.comuser2 user2email@domain.comuser3 user3email@domain.comWhen user account gets renewed, his name gets removed from the /tmp/overquotauser.txtNow what I want is to send email to these users, its easy but what I want is to prevent repeated email to user every hour. Example is if a user have consumed 80%, then only one email should send to user, and not every hour.any idea how this can be done?
prevent repeated emails via bash to overquote user
shell script;mysql
You can use a mysql table for this,since you are already working in mysql ! A table like this should suffice -create table (    userid varchar(100),    useremail varchar(100),    int mailsent default 0);Your creator job will create (or delete) rows from this table.Your mailer will pull all rows with mailsent set as 0, send mail, and set mailsent as 1. However, if you really, really, really want to use the text file - here is an approach -Let's say your creator cron job's first invocation creates a file like this -user1,user1@example.comuser2,user2@example.comuser3,user3@example.comNow at some time your mailer task runs , it will select the lines from this file that have emailid , mail the recipients and remove the email ids in those lines. ( You can use perl or sed for this - be careful of synchronous writing of this file from creator)after this operation your file will becomeuser1user2user3After a while your creator adds two more users user4 and user5. Your file now becomesuser1user2user3user4,user4@example.comuser5,user5@example.comWhen the mailer task runs again, it will email only to people who have email ids specified 0 as in step 2.There are multiple ways for this schema to work. 