Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Notify Of Expiry by date.

Quote Reply
Notify Of Expiry by date.
Hi all,

In our links database i want to create two fields for a date, one is a start date and one an end date, is there any way in which I can get links to notify me x-days before the expiry date by email?





Regards

MDJ1
http://www.isee-multimedia.co.uk
mark@isee-multimedia.co.uk
Quote Reply
Re: Notify Of Expiry by date. In reply to
You'd need to run a cron job that selects links from the database based on the expiration date, and emails the list to you.

Not terribly hard, and might have already been done in some easily modified form.

Something like:

SELECT ID,Title, URL from Links where CURDATE() <= DATE_ADD(Expire_Date, INTERVAL 5 DAY)

Then take the results and send them to yourself.


http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/

Quote Reply
Re: Notify Of Expiry by date. In reply to
I see so i could write a cron job (have no idea how to do this) to query the SQL database and then send me the results. am i on the right lines??



Regards

MDJ1
http://www.isee-multimedia.co.uk
mark@isee-multimedia.co.uk
Quote Reply
Re: Notify Of Expiry by date. In reply to
You'd have to write a perl script that accesses the MySQL table where the data is located. Then through your crontab manager via telnet, you would create a crontab for executing the script.

For more information about crontab, refer to the FAQ for Links 2.0 about executing the nph-build.cgi via Cron.

Wink

Regards,

Eliot Lee
Quote Reply
Re: Notify Of Expiry by date. In reply to
You could do it either in perl, or as a shell script if you have access to the mysql interpreter directly. You could feed the select command into the mysql program, and pipe the output to sendmail.

It's probably easiest to write a short perl program that executes the select statement, puts the results into an "OUTFILE" and then mails the file to yourself. (This prevents you from having to iterate the results of the select and put each line into a variable to send.)

To use sendmail is really easy on most systems, check out the BNB Reccomend It script for a good example of how to call sendmail from a perl script.



http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/