473,480 Members | 1,943 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

php and cron

I don't know if this is possible, but I need to accomplish an action
at a given hour (what cron does): is it possible to do something like
this having a web hosting service with php support?

any other possibilities to do something like this without having
access to cron facilities?

thanks
giammy

Sep 7 '06 #1
6 1800
On 2006-09-07 14:32:49 +0200, "giangiammy" <gi********@gmail.comsaid:
I don't know if this is possible, but I need to accomplish an action
at a given hour (what cron does): is it possible to do something like
this having a web hosting service with php support?
Yes, if you are able to set cron jobs on your web server. Save your
script in a PHP file like
#!/usr/bin/php
<?php

// Your code here

?>

and call it directly in your cron tab. Don't forget to make it
executable (chmod +x myscript.php or similar).
any other possibilities to do something like this without having
access to cron facilities?
If you are not able to set cron jobs on your server, then you might
want to try this site:

http://www.webcron.org/index.php?&lang=en
thanks
giammy
Sep 7 '06 #2
Francois Bonzon wrote:
On 2006-09-07 14:32:49 +0200, "giangiammy" <gi********@gmail.comsaid:
>I don't know if this is possible, but I need to accomplish an action
at a given hour (what cron does): is it possible to do something like
this having a web hosting service with php support?

Yes, if you are able to set cron jobs on your web server. Save your
script in a PHP file like
#!/usr/bin/php
<?php

// Your code here

?>
....this will only work if you happen to have the CLI PHP in /usr/bin/php and
have permissions to run it. If not, but assuming you have shell access, you
could try accessing a URL using wget or curl.

If you don't have access to cron (or at) you could still write a daemon
process that wakes up at intervals to do its stuff - see sleep().

HTH

C.
Sep 7 '06 #3
*** giangiammy escribió/wrote (7 Sep 2006 05:32:49 -0700):
I don't know if this is possible, but I need to accomplish an action
at a given hour (what cron does): is it possible to do something like
this having a web hosting service with php support?

any other possibilities to do something like this without having
access to cron facilities?
If the schedule is flexible enough and you just want to do it "once a day"
and the like... and taking for granted you do have a web site... A possible
approach is to launch the script from your site. Let me explain:

1) You put your code in a file

2) You choose a page on your site (or maybe an include file)

3) You get a random number and decided upon it whether the script will be
launched
// Not tested!
if(mt_rand(1, 1000)){
system('nohup /foo/var.php &');
}

You can make additional checks so it won't be executed in less than X
hours.
--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Sep 7 '06 #4
There are webservices that "visit" a page at specific times. Not really
secure, but it is easy to set up.

adlerweb

giangiammy schrieb:
I don't know if this is possible, but I need to accomplish an action
at a given hour (what cron does): is it possible to do something like
this having a web hosting service with php support?

any other possibilities to do something like this without having
access to cron facilities?

thanks
giammy
Sep 8 '06 #5
jl

adlerweb wrote:
There are webservices that "visit" a page at specific times. Not really
secure, but it is easy to set up.

adlerweb
Will you post some links of some of the web services that do this?

Thanks,
jl

Sep 8 '06 #6

jl wrote:
adlerweb wrote:
There are webservices that "visit" a page at specific times. Not really
secure, but it is easy to set up.

adlerweb

Will you post some links of some of the web services that do this?

Thanks,
jl
i found this:

http://www.webcron.org

Sep 9 '06 #7

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

Similar topics

6
2657
by: sherryonline | last post by:
i have a page and i need that page to be called every day at 12:00 that page is going to connect to the database fetch some emails and will start mailing them how i am goning to do this.
4
3031
by: vagrantbrad | last post by:
I'm using python 2.4 running on Fedora Core 4. I have written a python program called ipscan.py that checks the external ip address of my cable internet connection, and on change, will update the...
3
10286
by: the.natalie | last post by:
Hi. I am a newbie to mysql, cron, and shell scripting, so please bear with me. I have a script that is used for updating an image directory based on contents in a database. The script does the...
5
3534
by: jcor | last post by:
Hi, I'm trying to run my first cron job, probably it's missing something. I created a perl script just to test, it's called "teste" !/usr/bin/perl open(DATA,">>/home/joao/files/output"); @Now...
4
3908
by: Phil | last post by:
I have a php script that queries some Oracle DB and outputs a single line of plain text with <brat the end for each query. This is Apache2, php4.4.8 and Oracle Instant Client 10.1.0.5 all on CentOS...
5
2308
by: Lawrence Krubner | last post by:
Do any problems come up when using a static variable in a cron job? Assuming the cron job is called every 5 minutes for one year. Assume I've got an array that stores the names of which users are...
4
7482
by: Stephen Cattaneo | last post by:
Hello all, I am attempting to execute an automated test (written in Python) via cron. I have to check the HOSTNAME variable as part of the test, oddly under cron the HOSTNAME environment...
0
3412
by: Cameron Simpson | last post by:
On 17Aug2008 21:25, John Nagle <nagle@animats.comwrote: Because $HOSTNAME is a bash specific variable, set by bash but NOT EXPORTED! Like $0 and a bunch of other "private" variables, subprocesses...
1
2277
by: Karthik Gurusamy | last post by:
Hi, I'm working on a cron like functionality for my application. The outer loops runs continuously waking every x seconds (say x=180, 300, ..). It needs to know what events in cron has expired...
0
7037
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,...
1
6732
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
6886
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...
1
4768
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...
0
4472
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
2990
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...
0
1294
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
558
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
174
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.