473,474 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Automated Script

Guys, I need to make an automated script that runs every x seconds
without using a CRON job.

I heard there was a way doing it only in PHP. If you know any function
that can be used please inform me about it.

Oct 4 '05 #1
5 1902
not possible using php only.

three possible ways around:

1. use some web based cron (can't remember an url at the moment, sorry)

2. if you have a local pc that's online 24h, have a little program
there calling the automated script every x seconds

3. use the most frequented page of your website to call the automated
script (using a blind image, for instance). you'd have to include a
timer in the automated script than.

micha

Oct 4 '05 #2
chotiwallah wrote:
not possible using php only.

three possible ways around:

1. use some web based cron (can't remember an url at the moment, sorry)

2. if you have a local pc that's online 24h, have a little program
there calling the automated script every x seconds

3. use the most frequented page of your website to call the automated
script (using a blind image, for instance). you'd have to include a
timer in the automated script than.


You could use an infinite loop and stick the code to be executed inside
with a sleep at the end.

$x = 5;
while(1) {
echo "Hello world";
sleep($x);
}

Or if you want to re-execute the code a set number of times use:

$x = 5;
$y = 10;
for ($c = 0; $c < $y; $c++) {
echo "Hello world";
sleep(5);
}

--
Andrew @ Rockface
np: Sylvie - Smoke and Mirrors [stopped]
www.rockface-records.co.uk
Oct 4 '05 #3
On Tue, 4 Oct 2005 07:50:59 +0000 (UTC), Andrew @ Rockface wrote:
chotiwallah wrote: You could use an infinite loop and stick the code to be executed inside
with a sleep at the end.

$x = 5;
while(1) {
echo "Hello world";
sleep($x);
}


I've been digging around looking for info on precisely this topic.

Not sure whether your code will work (infinitely). It will simply hit
the maximum page execution time set by php.ini on the server - then
throw an ugly error.

You could extend that time with ini_set() - but I'm not sure whether
there's a memory or performance hit on a server processing an infinite
loop. It would also dependon what is actually happeniong iside the
loop.

Adam.
Oct 4 '05 #4
Adam wrote:
On Tue, 4 Oct 2005 07:50:59 +0000 (UTC), Andrew @ Rockface wrote:

chotiwallah wrote:


You could use an infinite loop and stick the code to be executed inside
with a sleep at the end.

$x = 5;
while(1) {
echo "Hello world";
sleep($x);
}

I've been digging around looking for info on precisely this topic.

Not sure whether your code will work (infinitely). It will simply hit
the maximum page execution time set by php.ini on the server - then
throw an ugly error.

You could extend that time with ini_set() - but I'm not sure whether
there's a memory or performance hit on a server processing an infinite
loop. It would also dependon what is actually happeniong iside the
loop.


True.

I generally run php scripts using wget from a crontab job. In fact I do
that every hour to run remote tests on around 60 sites and have found
it's perfect for the job.

--
Andrew @ Rockface
np: (Winamp is not active ;-)
www.rockface-records.co.uk
Oct 4 '05 #5
chotiwallah wrote:
not possible using php only.

three possible ways around:

1. use some web based cron (can't remember an url at the moment, sorry)
FWIW, it's webcron.com

<snip>
3. use the most frequented page of your website to call the automated
script (using a blind image, for instance)


FWIW, you don't have to go for webbug, it's enough that you put your
own cron_handler() function in frequently accessed PHP file. May also
use auto_prepend_file feature
<http://in2.php.net/ini.core#ini.auto-prepend-file>, (but it's a
discouraged approach). But, as you said, it's like reinventing the
wheel.

Possibly, the pure PHP solution is to use sleep() function and set
the maximum execution time to 0 (no limit) and to use it in command
line (so, that it doesn't use webserver resources).

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Oct 6 '05 #6

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

Similar topics

5
by: FoxRunner | last post by:
Hi folks, I got a script which restores a database. It works fine if it is running in my Query Analyzer. It fails when I put this script in an automated schedule using the SQL agent. This...
13
by: Benny | last post by:
Dear All, I need to send a set of Emails from my application (reminders) each month 1st. Is there anyway in ASP scripts to trigger an event to run automatically? I have no dedicated server, so...
4
by: Civilian_Target | last post by:
Is there any way in DB2 to automate the taking of a snapshot, for example, a function that will cause a db2 snapshot to be taken every 5 minutes and written to a uniquely named file? Am I better...
5
by: murrayatuptowngallery | last post by:
I'm caught in a classic finger-pointing situation. My hosting company's server appears to be automatically inserting JS tags into a JS-free html page that has an image inked to a 2nd page with...
7
by: enko | last post by:
Our company has developed a web-app that needs the ability to run a regular maintenance PHP script and use it also send out SMS/Email alerts on a regular basis, say at exactly 9AM and 2PM without...
6
by: brettev | last post by:
World, I work at a university where the professors have a system to input grades for assignments and calculate final grades, which is output to an excel file. they are then required to get on a...
3
by: aj | last post by:
DB2 LUW 8.2 FP14 Red Hat AS 2.1 I am using a response file w/ db2setup to install DB2. I then want to install the latest fixpak in the same automated way. Is there any way to use a response...
9
by: Steve Poe | last post by:
I work for an animal hospital trying to use PHP to store an animal's dental x-rays to a file server. I can browse for the xray on the local desktop computer then click "Upload Image". This...
1
by: lanlife | last post by:
Hello All, I am building an application which i will like to send an automated sms through a gateway to gsm phone numbers.I want it to query the database to get data at a particular time and...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.