473,396 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to schedule script without cron?

Is there a way to get my script to run on regularly scheduled intervals
without using cron? My hosting provider sucks... cannot use cron... I was
thinking perhaps I could create a file every hour in a certain directory and
then fire the script when the file count reaches a certain number, and then
clear out the directory... or something like that. Any suggestions?

Thanks in advance.
Jul 17 '05 #1
29 11213

"deko" <no****@hotmail.com> wrote in message
news:gz*****************@newssvr25.news.prodigy.co m...
Is there a way to get my script to run on regularly scheduled intervals
without using cron? My hosting provider sucks... cannot use cron... I was thinking perhaps I could create a file every hour in a certain directory and then fire the script when the file count reaches a certain number, and then clear out the directory... or something like that. Any suggestions?

Thanks in advance.


You would need cron to create the file every hour unfortunately.

Maybe if one of your friends has a linux box you could get him to set a cron
job that point lynx at the script every so often, or else maybe leave a
browser window open on your machine with a window set to refresh every so
often (with meta refresh or whatever)
Jul 17 '05 #2
"deko" <no****@hotmail.com> wrote in
news:gz*****************@newssvr25.news.prodigy.co m:
Is there a way to get my script to run on regularly scheduled
intervals without using cron? My hosting provider sucks... cannot use
cron... I was thinking perhaps I could create a file every hour in a
certain directory and then fire the script when the file count reaches
a certain number, and then clear out the directory... or something
like that. Any suggestions?

Thanks in advance.


on your most visited webpage, use some server side code that checks the
time and if it falls withing your interval range, then run some code.
--
Edward Alfert
http://www.rootmode.com/
Multiple Domain Hosting and Reseller Hosting Plans
Coupon Code (Recurring $5/month Discount): newsgroup

Jul 17 '05 #3
> You would need cron to create the file every hour unfortunately.

yeah, I suppose that just begs the question.
Maybe if one of your friends has a linux box you could get him to set a cron job that point lynx at the script every so often, or else maybe leave a
browser window open on your machine with a window set to refresh every so
often (with meta refresh or whatever)


I have a few linux boxes. So I set up a cron to visit my hosted site? Not
sure what you mean...
Jul 17 '05 #4
> on your most visited webpage, use some server side code that checks the
time and if it falls withing your interval range, then run some code.


That sounds interesting. The key is keeping the schedule.

What I want to do is keep a count of page hits in a 24-hour period, 30-day
period, and 365-day period. I can assume there will always be at least one
hit in a 24-hour period.
Jul 17 '05 #5
deko wrote:
Is there a way to get my script to run on regularly scheduled intervals
without using cron? My hosting provider sucks... cannot use cron... I
was thinking perhaps I could create a file every hour in a certain
directory and then fire the script when the file count reaches a certain
number, and then
clear out the directory... or something like that. Any suggestions?

Thanks in advance.


Short answer:

user@host:~> nohup bash -c '
while true ; do
echo run your prog here
sleep 3600
done'

((((then ctrl-Z))))))
user@host:~> bg
user@host:~> exit
---------------------------
better answer:

read http://www.icon.co.za/~psheer/rute-home.html

C.
Jul 17 '05 #6
deko wrote:
Is there a way to get my script to run on regularly scheduled intervals
without using cron? My hosting provider sucks... cannot use cron... I was
thinking perhaps I could create a file every hour in a certain directory and
then fire the script when the file count reaches a certain number, and then
clear out the directory... or something like that. Any suggestions?

Thanks in advance.


create a "master" process, execute it in the background
$ ./timer &

that is in a loop:

loop
if nextinterval do something
wait until nextintervaltime
goto loop

unless you are able to have access to the system level, you are out of luck.
Any process not assoiciated with the server itself, would probably be detecteced
and killed. Do yourself a favor, spend a few extra bucks, get DSL or Cable at a
level that will allow you to run your own server (and use a hardware firewall).
This can be done using DynamicDNS (static IP not necessary). You will not be
able to use outbound SMTP because your IP address does not backtranslate, but
that is no big deal. I use DDNS for inbound POP SMTP and my ISP for outbound.
If your ISP has a history of lots of downtime during the day, then you may need
to look for something more stable.

If they reboot the system for maintenance or whatever, you will have to restart
your script. Use a box that you have control over... Trying to use ISP
"freebies" is really bad idea. Bottom line: if it is that important, get your
own system to work with... BTW, I have 2 Linux boxes and one OpenVMS box on the
net using DDNS (zoneedit.com)... All can do {L|V}AMP, but they also do a lot more :)

--
Michael Austin.
Consultant - Available.
Donations welcomed. Http://www.firstdbasource.com/donations.html
:)
Jul 17 '05 #7

"deko" <no****@hotmail.com> wrote in message
news:UJ*****************@newssvr25.news.prodigy.co m...
You would need cron to create the file every hour unfortunately.
yeah, I suppose that just begs the question.
Maybe if one of your friends has a linux box you could get him to set a

cron
job that point lynx at the script every so often, or else maybe leave a
browser window open on your machine with a window set to refresh every so often (with meta refresh or whatever)


I have a few linux boxes. So I set up a cron to visit my hosted site?

Not sure what you mean...


Right, Lets say your hosted site (domain.com) has a phpscript in /php/
called dorun.php that needs to be run every hour, every day add the
following line to your crontab

5 * * * 0-6 lynx http://www.domain.com/php/dorun.php

(I think that is correct, it's been a while since I have used cron)
Jul 17 '05 #8
> on your most visited webpage, use some server side code that checks the
time and if it falls withing your interval range, then run some code.


this is what the log looks like:

Jul 13 2004 06:30 pm|68.110.65.241|Windows 95|MSIE 5|pacbell.net
Jul 13 2004 06:32 pm|68.127.69.101|Windows 95|MSIE 5|pacbell.net
Jul 13 2004 06:34 pm|203.12.69.231|Windows 95|MSIE 5|pacbell.net
Jul 13 2004 06:36 pm|64.122.69.141|Windows 95|MSIE 5|pacbell.net
Jul 13 2004 06:38 pm|68.110.69.26|Windows 95|MSIE 5|pacbell.net

so if I can somehow analyze the date column...

if the bottom visit is less than [time() - 3600 * 24] then
move to the next line
else
run script

does this sound about right?
Jul 17 '05 #9
"deko" <no****@hotmail.com> wrote in
news:VN*****************@newssvr25.news.prodigy.co m:
on your most visited webpage, use some server side code that checks
the time and if it falls withing your interval range, then run some
code.


That sounds interesting. The key is keeping the schedule.

What I want to do is keep a count of page hits in a 24-hour period,
30-day period, and 365-day period. I can assume there will always be
at least one hit in a 24-hour period.


On every page load write the current date (not time) to a text file and
compare it to the previous line. If the date has changed, then count the
number of lines in the file (minus 1) and that is the number of hits the
previous day. Write this number to a different file including yesterday's
date and count.
--
Edward Alfert
http://www.rootmode.com/
Multiple Domain Hosting and Reseller Hosting Plans
Coupon Code (Recurring $5/month Discount): newsgroup

Jul 17 '05 #10
"deko" <no****@hotmail.com> wrote in news:uZaJc.10316$8Y.3454
@newssvr25.news.prodigy.com:
on your most visited webpage, use some server side code that checks the
time and if it falls withing your interval range, then run some code.


this is what the log looks like:

Jul 13 2004 06:30 pm|68.110.65.241|Windows 95|MSIE 5|pacbell.net
Jul 13 2004 06:32 pm|68.127.69.101|Windows 95|MSIE 5|pacbell.net
Jul 13 2004 06:34 pm|203.12.69.231|Windows 95|MSIE 5|pacbell.net
Jul 13 2004 06:36 pm|64.122.69.141|Windows 95|MSIE 5|pacbell.net
Jul 13 2004 06:38 pm|68.110.69.26|Windows 95|MSIE 5|pacbell.net

so if I can somehow analyze the date column...

if the bottom visit is less than [time() - 3600 * 24] then
move to the next line
else
run script

does this sound about right?


Doesn't your host provide analog, webalizer, awstats, or any of the other
free log analysys programs?

If not, does your hosting provide php and mysql?

Just log every visit to a mysql database and whenever you want to know
anything about your traffic pattern, query the database.

Select count(date) from visitors where date = dateyouwhattoknow;

You can create whatever sql statement you want. This is the way I would do
it.

--
Edward Alfert
http://www.rootmode.com/
Multiple Domain Hosting and Reseller Hosting Plans
Coupon Code (Recurring $5/month Discount): newsgroup

Jul 17 '05 #11
> create a "master" process, execute it in the background
$ ./timer &

that is in a loop:

loop
if nextinterval do something
wait until nextintervaltime
goto loop

unless you are able to have access to the system level, you are out of luck. Any process not assoiciated with the server itself, would probably be detecteced and killed. Do yourself a favor, spend a few extra bucks, get DSL or Cable at a level that will allow you to run your own server (and use a hardware firewall). This can be done using DynamicDNS (static IP not necessary). You will not be able to use outbound SMTP because your IP address does not backtranslate, but that is no big deal. I use DDNS for inbound POP SMTP and my ISP for outbound. If your ISP has a history of lots of downtime during the day, then you may need to look for something more stable.

If they reboot the system for maintenance or whatever, you will have to restart your script. Use a box that you have control over... Trying to use ISP
"freebies" is really bad idea. Bottom line: if it is that important, get your own system to work with... BTW, I have 2 Linux boxes and one OpenVMS box on the net using DDNS (zoneedit.com)... All can do {L|V}AMP, but they also do a

lot more :)

I was looking at DDNS a few weeks ago, but decided to go with a hosting
provider for portability purposes - that is, if I move, or change hosting
providers, my site is still up and email keeps coming. So uptime was
important, and also speed...

I do not have access to the server at my hosting provider, so, as you say,
I'm out of luck in terms of using a process-based schedule.
Jul 17 '05 #12
> user@host:~> nohup bash -c '
while true ; do
echo run your prog here
sleep 3600
done'


that is a good suggestion, but I think a file-based solution might be more
reliable - for example, what if the server gets rebooted or something.
Jul 17 '05 #13
> Right, Lets say your hosted site (domain.com) has a phpscript in /php/
called dorun.php that needs to be run every hour, every day add the
following line to your crontab

5 * * * 0-6 lynx http://www.domain.com/php/dorun.php


That sound like it would work, but then, potentially, anyone could kick off
my script. Is this correct? Also, forgive my ignorance, but what is lynx?
Jul 17 '05 #14
> On every page load write the current date (not time) to a text file and
compare it to the previous line. If the date has changed, then count the
number of lines in the file (minus 1) and that is the number of hits the
previous day. Write this number to a different file including yesterday's
date and count.


I have the counter script already written - but I want to update the figures
every three hours and maintain a rolling count. So, every three hours the
figures for each interval (24h, 30d, 365d) are updated. This would be easy
to do with cron, but alas, cron cannot be used...
Jul 17 '05 #15
> Doesn't your host provide analog, webalizer, awstats, or any of the other
free log analysys programs?
Yes, but this has a special purpose
If not, does your hosting provide php and mysql?


Yes, but I need a file-based solution

Jul 17 '05 #16
> > Jul 13 2004 06:30 pm|68.110.65.241|Windows 95|MSIE 5|pacbell.net
Jul 13 2004 06:32 pm|68.127.69.101|Windows 95|MSIE 5|pacbell.net
Jul 13 2004 06:34 pm|203.12.69.231|Windows 95|MSIE 5|pacbell.net
Jul 13 2004 06:36 pm|64.122.69.141|Windows 95|MSIE 5|pacbell.net
Jul 13 2004 06:38 pm|68.110.69.26|Windows 95|MSIE 5|pacbell.net

so if I can somehow analyze the date column...

if the bottom visit is less than [time() - 3600 * 24] then
move to the next line
else
run script

does this sound about right?


Is there a way to get file modification time in php? Perhaps I could just
check the mod date of a file with each visit.

For example, each time the site is visited, write something to a file.
Then, a separate script checks that file's mod date. If the mod date is 3
hours old, then run the script. Do you think this would work?
Jul 17 '05 #17

"deko" <no****@hotmail.com> wrote in message
news:E6*****************@newssvr25.news.prodigy.co m...
Right, Lets say your hosted site (domain.com) has a phpscript in /php/
called dorun.php that needs to be run every hour, every day add the
following line to your crontab

5 * * * 0-6 lynx http://www.domain.com/php/dorun.php
That sound like it would work, but then, potentially, anyone could kick

off my script. Is this correct? Also, forgive my ignorance, but what is lynx?


lynx is a text based browser that ships with most linux distros.

You could always put a clause in the script to only allow you to run it (For
example must have a certain password, or http authentication.) but otherwise
anyone could run it yes.
Jul 17 '05 #18
"deko" <no****@hotmail.com> wrote in
news:Ki****************@newssvr25.news.prodigy.com :
> Jul 13 2004 06:30 pm|68.110.65.241|Windows 95|MSIE 5|pacbell.net
> Jul 13 2004 06:32 pm|68.127.69.101|Windows 95|MSIE 5|pacbell.net
> Jul 13 2004 06:34 pm|203.12.69.231|Windows 95|MSIE 5|pacbell.net
> Jul 13 2004 06:36 pm|64.122.69.141|Windows 95|MSIE 5|pacbell.net
> Jul 13 2004 06:38 pm|68.110.69.26|Windows 95|MSIE 5|pacbell.net
>
> so if I can somehow analyze the date column...
>
> if the bottom visit is less than [time() - 3600 * 24] then
> move to the next line
> else
> run script
>
> does this sound about right?


Is there a way to get file modification time in php? Perhaps I could
just check the mod date of a file with each visit.

For example, each time the site is visited, write something to a file.
Then, a separate script checks that file's mod date. If the mod date
is 3 hours old, then run the script. Do you think this would work?


yes... take a look at user comments at
http://www.php.net/manual/en/function.fileatime.php
--
Edward Alfert
http://www.rootmode.com/
Multiple Domain Hosting and Reseller Hosting Plans
Coupon Code (Recurring $5/month Discount): newsgroup

Jul 17 '05 #19
> You could always put a clause in the script to only allow you to run it
(For
example must have a certain password, or http authentication.) but otherwise anyone could run it yes.


Perhaps I could check the modification date of a file with php and base my
scheduling on that. I could use lynx simply to visit the site at 12:00 each
day, which would create a benchmark file. Then my script checks the mod
date of that file... woudl this work? How to check the mod date of a file
with php?

I would like to know more abotu using lynx and authentication - for example,
can I automate a login to my bank's online banking page to get my bank
balance each day? Of course, that site uses encription and probally a bunch
of other security I don't understand...

Jul 17 '05 #20
> > Is there a way to get file modification time in php? Perhaps I could
just check the mod date of a file with each visit.

For example, each time the site is visited, write something to a file.
Then, a separate script checks that file's mod date. If the mod date
is 3 hours old, then run the script. Do you think this would work?


yes... take a look at user comments at
http://www.php.net/manual/en/function.fileatime.php


I think that's the answer... Thanks!!
Jul 17 '05 #21

"deko" <no****@hotmail.com> wrote in message
news:nx******************@newssvr25.news.prodigy.c om...
You could always put a clause in the script to only allow you to run it (For
example must have a certain password, or http authentication.) but

otherwise
anyone could run it yes.


Perhaps I could check the modification date of a file with php and base my
scheduling on that. I could use lynx simply to visit the site at 12:00

each day, which would create a benchmark file. Then my script checks the mod
date of that file... woudl this work? How to check the mod date of a file
with php?
http://ie2.php.net/manual/en/function.filemtime.php


I would like to know more abotu using lynx and authentication - for example, can I automate a login to my bank's online banking page to get my bank
balance each day? Of course, that site uses encription and probally a bunch of other security I don't understand...


I don't know about your bank, but mine uses java, activex, javascript and a
bunch of other crap lynx can not support, so I would not be able to get past
the login screen.

HTTP Authentication on the other hand is achieved through .htaccess and
..htpasswd (Or it can be done through PHP too)

A page using HTTP Authentication can be accessed in the following manner.

http://user:pa******@domain.com

Thus allowing it to be easily accessed from a browser launched via cron
while also giving it some measure of security.
HTTP AUTHENTICATION IN PHP (This will only work on apache afaik)

<?php

if ((!isset($PHP_AUTH_USER) || $PHP_AUTH_USER != "USERNAME") &&
(!isset($PHP_AUTH_PW) || $PHP_AUTH_PW != "ABERDEEN")) {
header("WWW-Authenticate: Basic realm=\"cronexample\"");
Header("HTTP/1.0 401 Unauthorized");
echo "<html><body bgcolor=efefef>";
echo "You must have a username and password to access this site.";
exit;
}
else if(($PHP_AUTH_USER=="USERNAME") && ($PHP_AUTH_PW=="PASSWORD"))
{
$cookiename = "auth";
$cookievalue = "ok";
$cookieexpire = time()+9200;
$cookiedomain = "";
setcookie($cookiename, $cookievalue, $cookieexpire, "/", $cookiedomain,
0);
}
?>

And you can do your file stuff here.
Jul 17 '05 #22
deko wrote:
create a "master" process, execute it in the background
$ ./timer &

that is in a loop:

loop
if nextinterval do something
wait until nextintervaltime
goto loop

unless you are able to have access to the system level, you are out of


luck.
Any process not assoiciated with the server itself, would probably be


detecteced
and killed. Do yourself a favor, spend a few extra bucks, get DSL or


Cable at a
level that will allow you to run your own server (and use a hardware


firewall).
This can be done using DynamicDNS (static IP not necessary). You will


not be
able to use outbound SMTP because your IP address does not backtranslate,


but
that is no big deal. I use DDNS for inbound POP SMTP and my ISP for


outbound.
If your ISP has a history of lots of downtime during the day, then you may


need
to look for something more stable.

If they reboot the system for maintenance or whatever, you will have to


restart
your script. Use a box that you have control over... Trying to use ISP
"freebies" is really bad idea. Bottom line: if it is that important, get


your
own system to work with... BTW, I have 2 Linux boxes and one OpenVMS box


on the
net using DDNS (zoneedit.com)... All can do {L|V}AMP, but they also do a


lot more :)

I was looking at DDNS a few weeks ago, but decided to go with a hosting
provider for portability purposes - that is, if I move, or change hosting
providers, my site is still up and email keeps coming. So uptime was
important, and also speed...

I do not have access to the server at my hosting provider, so, as you say,
I'm out of luck in terms of using a process-based schedule.


Unless it takes you more than 48 hours to move and get your new connection set
up, that shouldn't be a problem. I used ZoneEdits email "store-and-forward" as
a backup mail server. The mail just collected there while I moved from NC to
KC. The server was down for about 7-10 days - no email was missed... took a
while to read through them...

If you change providers you also may have to change registrars for your domain
name(some force the change - which is really stupid, but whatever...) When this
occurs, it takes 2-3 days for the new information to be propogated. So, using
DynDNS and registering the domain name yourself where you have control over the
technical information such as primary DNS etc... then it is actually a lot
better than trying to play by the minimalist rules of ISP-based hosting. You
have to play by their rules and applications.

--
Michael Austin.
Consultant - Available.
Donations welcomed. Http://www.firstdbasource.com/donations.html
:)
Jul 17 '05 #23
> I don't know about your bank, but mine uses java, activex, javascript and
a
bunch of other crap lynx can not support, so I would not be able to get past the login screen.

HTTP Authentication on the other hand is achieved through .htaccess and
.htpasswd (Or it can be done through PHP too)

A page using HTTP Authentication can be accessed in the following manner.

http://user:pa******@domain.com

Thus allowing it to be easily accessed from a browser launched via cron
while also giving it some measure of security.
HTTP AUTHENTICATION IN PHP (This will only work on apache afaik)

<?php

if ((!isset($PHP_AUTH_USER) || $PHP_AUTH_USER != "USERNAME") &&
(!isset($PHP_AUTH_PW) || $PHP_AUTH_PW != "ABERDEEN")) {
header("WWW-Authenticate: Basic realm=\"cronexample\"");
Header("HTTP/1.0 401 Unauthorized");
echo "<html><body bgcolor=efefef>";
echo "You must have a username and password to access this site.";
exit;
}
else if(($PHP_AUTH_USER=="USERNAME") && ($PHP_AUTH_PW=="PASSWORD"))
{
$cookiename = "auth";
$cookievalue = "ok";
$cookieexpire = time()+9200;
$cookiedomain = "";
setcookie($cookiename, $cookievalue, $cookieexpire, "/", $cookiedomain,
0);
}
?>

And you can do your file stuff here.

cool... I will play around with this. Thanks.
Jul 17 '05 #24
> Unless it takes you more than 48 hours to move and get your new connection
set
up, that shouldn't be a problem. I used ZoneEdits email "store-and-forward" as a backup mail server. The mail just collected there while I moved from NC to KC. The server was down for about 7-10 days - no email was missed... took a while to read through them...

If you change providers you also may have to change registrars for your domain name(some force the change - which is really stupid, but whatever...) When this occurs, it takes 2-3 days for the new information to be propogated. So, using DynDNS and registering the domain name yourself where you have control over the technical information such as primary DNS etc... then it is actually a lot
better than trying to play by the minimalist rules of ISP-based hosting. You have to play by their rules and applications.


I've already purchased a year of hosting, so I'll be using that for now -
but would like to set up another site with DDNS... I've got enough linux
boxes in teh garage... might as well put them onthe air... How do I get
started? Can you point me to a site that shows me how?
Jul 17 '05 #25
In article <gz*****************@newssvr25.news.prodigy.com> , deko wrote:
Is there a way to get my script to run on regularly scheduled intervals
without using cron? My hosting provider sucks... cannot use cron... I was
thinking perhaps I could create a file every hour in a certain directory and
then fire the script when the file count reaches a certain number, and then
clear out the directory... or something like that. Any suggestions?


You could look in the archives of this group. Question has been asked
many times before.

--
Tim Van Wassenhove <http://home.mysth.be/~timvw>
Jul 17 '05 #26
deko wrote:
on your most visited webpage, use some server side code that checks
the time and if it falls withing your interval range, then run some
code.


this is what the log looks like:

Jul 13 2004 06:30 pm|68.110.65.241|Windows 95|MSIE 5|pacbell.net
Jul 13 2004 06:32 pm|68.127.69.101|Windows 95|MSIE 5|pacbell.net
Jul 13 2004 06:34 pm|203.12.69.231|Windows 95|MSIE 5|pacbell.net
Jul 13 2004 06:36 pm|64.122.69.141|Windows 95|MSIE 5|pacbell.net
Jul 13 2004 06:38 pm|68.110.69.26|Windows 95|MSIE 5|pacbell.net

so if I can somehow analyze the date column...

if the bottom visit is less than [time() - 3600 * 24] then
move to the next line
else
run script

does this sound about right?


Would it not be easier to use the time () function ? (returns seconds passed
since 1-1-1970)
Simply write it to a file the first time.
Every next run compare time () to the stored version. If the difference in
seconds becomes larger than your desired interval, do your stuff and rewrite
the file with the new timestamp.
Pjotr
Jul 17 '05 #27
deko wrote:
Unless it takes you more than 48 hours to move and get your new connection


set
up, that shouldn't be a problem. I used ZoneEdits email


"store-and-forward" as
a backup mail server. The mail just collected there while I moved from NC


to
KC. The server was down for about 7-10 days - no email was missed... took


a
while to read through them...

If you change providers you also may have to change registrars for your


domain
name(some force the change - which is really stupid, but whatever...) When


this
occurs, it takes 2-3 days for the new information to be propogated. So,


using
DynDNS and registering the domain name yourself where you have control


over the
technical information such as primary DNS etc... then it is actually a lot
better than trying to play by the minimalist rules of ISP-based hosting.


You
have to play by their rules and applications.

I've already purchased a year of hosting, so I'll be using that for now -
but would like to set up another site with DDNS... I've got enough linux
boxes in teh garage... might as well put them onthe air... How do I get
started? Can you point me to a site that shows me how?


All you need is a router that can support port-forwarding. In fact, there are
tons of examples (google for linux broadband router) should get you started.

you can start at http://www.firstdbasource.com/ and click on "how do I put
openvms on broadband" you will have to make the appropriate technology
translations, but shouldn't be that difficult.

--
Michael Austin.
Consultant - Available.
Donations welcomed. Http://www.firstdbasource.com/donations.html
:)
Jul 17 '05 #28
> All you need is a router that can support port-forwarding. In fact, there
are
tons of examples (google for linux broadband router) should get you started.
you can start at http://www.firstdbasource.com/ and click on "how do I put
openvms on broadband" you will have to make the appropriate technology
translations, but shouldn't be that difficult.


Sounds interesteing - I'll take a look.

As for reworking my script to run without cron, I think I've got an idea....

Here is what the file looks like that contains a record of site visits:

Jul 14 2004 09:30 am|68.122.69.241|Windows Server|MSIE
6|pacbell.net|1089822637
Jul 14 2004 09:30 am|68.122.69.241|Windows Server|MSIE
6|pacbell.net|1089822644
Jul 14 2004 09:31 am|68.122.69.241|Windows Server|MSIE
6|pacbell.net|1089822679
Jul 14 2004 09:31 am|68.122.69.241|Windows Server|MSIE
6|pacbell.net|1089822686
Jul 14 2004 09:47 am|68.122.69.241|Windows Server|MSIE
6|pacbell.net|1089823630
Jul 14 2004 09:47 am|68.122.69.241|Windows Server|MSIE
6|pacbell.net|1089823638
Jul 14 2004 11:09 am|68.122.69.241|Windows Server|MSIE
6|pacbell.net|1089828547
Jul 14 2004 11:09 am|68.122.69.241|Windows Server|MSIE
6|pacbell.net|1089828553
Jul 14 2004 11:16 am|68.122.69.241|Windows Server|MSIE
6|pacbell.net|1089829014
Jul 14 2004 11:16 am|68.122.69.241|Windows Server|MSIE
6|pacbell.net|1089829019

The last column is time()

So, if I can count the number of lines in this file that are within the the
intervals in question, I'll have the count for each interval:

number of entries > time() - (3600*24) = $hr24
number of entries > time() - (3600*24*30) = $d30
number of entries > time() - (3600*24*365) = $d365

But how do I count lines in a file?

Jul 17 '05 #29
"deko" <no****@hotmail.com> wrote in message news:<gz*****************@newssvr25.news.prodigy.c om>...
Is there a way to get my script to run on regularly scheduled intervals
without using cron? My hosting provider sucks... cannot use cron... I was
thinking perhaps I could create a file every hour in a certain directory and
then fire the script when the file count reaches a certain number, and then
clear out the directory... or something like that. Any suggestions?


1. Fakecron
a. using PHP include/require
b. using webbug
2. 3rd party remote cron <http://hostedcron.com/>

--
| Just another PHP saint |
Email: rrjanbiah-at-Y!com
Jul 17 '05 #30

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Timo-Pekka Oikarinen | last post by:
Is there PHP chat script *without* MySQL? Demands: absolutely FREE (no adware, shareware etc.), No MySQL needed, one permanent public chat, can make your own channels (public/private) like IRC,...
5
by: deko | last post by:
In regard to running php scripts with cron - Here is a sample script: <?php //debug.php echo "<br> This is a test"; ?> I can call debug.php from a web page on my site like this:
2
by: erikcw | last post by:
Hi all, When trying to run this python script from cron, I get the following error: Traceback (most recent call last): File "/home/lybp/public_html/wa/wa.py", line 14, in ? import MySQLdb...
1
by: vaskarbasak | last post by:
Hi All, how will i set shell script on cron tab to execute the script? please help me. Thanks! Vaskar
2
by: smitanaik | last post by:
i have a java file which i am running through shell script. the syntax that i have used is #! /bin/bash javac Copy.java
1
by: djpaul | last post by:
Hello, I am just a newbie to javascript, but the most stuff i do is in php or .net. But, now i have 2 buttons on my script that are calling a javascript function as shown below (OnClick""). Now...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.