473,545 Members | 2,047 Online
Bytes | Software Development & Data Engineering Community
+ 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 1909
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_fi le feature
<http://in2.php.net/ini.core#ini.au to-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
9114
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 is my script
13
1793
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 no DLLs or Scheduler scripts can be used. Also adding the trigger script in the application object may not send emails in time, as we have not enough...
4
3206
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 off attempting to do this with my poor knowledge of dos batch files? I'm running UDB 8.2 on Windows 2000. Thanks.
5
3494
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 JS. The problem may well be that I am calling JS incorrectly. My host co. insists my ''web publishing software' is doing this. I can prove it...
7
2283
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 user interaction. We're using shared hosting at the moment, so we have no access anything more than our file directory on the server and our...
6
3045
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 different system and click radio buttons in a form to input final grades. i would like to automate this by doing some sort of automated form...
3
2804
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 file w/ fixpak installation? Or can I otherwise do an automated (non-interactive) fixpak install?
9
3879
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 works fine. The doctors want fewer steps to follow. So, it was asked if I can configure the browser to load/submit the image 'xray.tif' each time they...
1
2092
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 send. e.g an automated script that send happy birthday to someone by checking the birthday information in the database to send immediately it happens or...
0
7475
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7918
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7436
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7766
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5981
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1897
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 we have to send another system
1
1022
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
715
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.