Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running a perl script automatically 1

Status
Not open for further replies.

fortwilliam

Programmer
Mar 5, 2008
7
GB
I have a newsletter system and want to have it work automatically. what I have so far works with a visitor to a page with a tiny iframe in it. This iframe calls up the send.pl newsletter script. Trouble is that if the visitor refreshes the page before the script has finished, duplicate emails are sent out. Or if they leave the page before the perl script has finished, not all emails are sent.

When the script is finished, I have it write to a text file with a year and day value so that no more emails will be sent until the next day. I tried writing to this text file at the very start of the script, but if the visitor refreshed the page, not all emails are sent.

What way could I use to have the script carry on doing its thing regardless of what the visitor to the page does. What I want is for the visitor to trigger the perl script within the iframe and that is all that is required. After that the script works away itself in the background, happily sending out the scheduled messages.

Thanks.
 
It sounds like you need to divorce yourself from the idea of having the vistor trigger the news letter. See about setting up a cronjob (linux/Unix) or a task (windows).

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Is the server Unix? Unix can ignore the signals that are probably killing your process.

eugene
 
Thanks for the replies. I am reading up on cron jobs at the moment.

elgrandeperro : Linux.
 
I set up a cronjob and it does exactly what I need. So very much easier than how I was attempting to get it done.

Thanks very much.
 
Let the other forum you posted on know your question has been resolved. You're welcome.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top