Page 1 of 1

Making Things "Automatic"

Posted: Sun Aug 03, 2003 6:22 pm
by Mr. Tech
Hi!

I have a script that records statistics and want it to send the statistic to me via email everyday automatically without me even visiting the site.

How would I get it to send it to me automatically?

Thanks

Ben

Posted: Sun Aug 03, 2003 6:42 pm
by jmarcv
Its called a 'cron' on Unix systems. Unfortunately, many hosts do not allow php to be run from the command line, which is how yiou would have to do it, and if yours doesn't option 2 is to learn Perl or C and write one, or hire someone to do it for you.
Option 3 is to put a machine in the closet with a browser always open to your script and use Javascript timers, PHP sleep command, or time checking to tell it when to run the script. But, as I said, unless your ISP allows php from a command line.....

Posted: Sun Aug 03, 2003 7:17 pm
by nielsene
or you can also have cron call wget or lynx to some "secret" web page tp trigger a web-verison of what should be a cli process..

Of course if a search engine finds your "secret" page you might start getting loads of stat rebuilds/emails.

Posted: Sun Aug 03, 2003 7:22 pm
by jmarcv
nielsene

Hmmm... I'll look into that. I too once wanted to avoid perl.

Of course, we just had the discussion on the problems with $HTTP_REFERER, but you could probably check the IP to make sure it is only triggered internally?

Posted: Sun Aug 03, 2003 8:25 pm
by Drachlen
Although this system isnt perfect, and does depend on traffic, you could set up a script that is at the top of the page and always running no matter where the user is on the site. set up a time stamp field, and have it check it each page. once its at the time you want, submit the stats to you through email. This is what im using for deleting old accounts and logging people off when they arent active, so far it works fine... Or you could put together a javascript clock and when it reaches zero have it forward to the execute page, and have a header on the execute page to go back to the clock, and just run this on the server, not sure if it could slow anything down if its only done once every 24 hours...

Posted: Mon Aug 04, 2003 1:09 am
by Mr. Tech
hmmm... I didn't realise it would be so hard... I noticed a program called phpAdsNew was able to send emails at any time...

Posted: Mon Aug 04, 2003 8:20 am
by jmarcv
Mr. Tech wrote:hmmm... I didn't realise it would be so hard... I noticed a program called phpAdsNew was able to send emails at any time...
Yeah, well what does that have to do with it? You don't know how they do it. They are probably just using a listserv or something.

Not hard. Hell, I've read a lot of easy options here.