473,769 Members | 4,591 Online
Bytes | Software Development & Data Engineering Community
+ 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 1823
On 2006-09-07 14:32:49 +0200, "giangiammy " <gi********@gma il.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********@gma il.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
2679
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
3052
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 dns records at my dns provider, zoneedit. So basically, I've setup dynamic dns using python. Once the ip compare and/or update is complete, I log the results to a text file called update.log. When I run the program in a bash shell with the...
3
10313
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 following: runs several queries against different tables in a database; returns several lists of pictures being used in the database; removes any obsolete images from specific directories. The script is bash shell script. The problem is that...
5
3547
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 = localtime(time); print DATA "@Now\n"; exit ;
4
3959
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 4.4 32bit. Php does run as an Apache SO. It works perfectly if I just hit the page in a web-browser (output to browser). It works *perfectly* from the command line (dumps the text to the file per the redirect)
5
2326
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 logged in to a particular website at the current moment. Would it cause me trouble if I made this array static? If it would cause trouble, what's the easiest way to persist the data? I could use a database, but that seems heavy handed for a 20...
4
7562
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 variable is not in the os.environ dictionary. I know that cron runs in a subshell that does not have all of the normally set environment variables. HOSTNAME is not one of those variables, it is set even in cron's subshell. Why doesn't python get...
0
3477
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 do not inherit this value. From "man bash": Shell Variables The following variables are set by the shell:
1
2312
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 and for each event do the work needed. It's basically like unix cron or like a calendar application with some restrictions. The outer loop may come back a lot later and many events
0
10223
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
9866
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...
0
8879
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
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
6675
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
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3968
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
3571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.