473,915 Members | 5,967 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 1923
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
9137
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
1818
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 visitors to that application. Is there any way other than 'Clicking a Send button'? Any support...
4
3240
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
3514
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 isn't by deleting the offending code with an impotent text editor like Notepad, upload it with a WS_FTP...
7
2297
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 database. To resolve this I've created a small vb.net app that accesses the maintenance script on our...
6
3068
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 submission that grabs the information from the excel sheet and selects the correct radio button and then...
3
2822
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
3911
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 click "Upload Image" instead of the doctor/animal technician having to look for for dental x-ray...
1
2106
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 as stipulated. Any help will be appreciated. Thank you in Advance.
0
11354
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10923
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10542
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7256
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5943
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4778
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
2
4344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.