Page 1 of 2
Back-end execution
Posted: Fri Aug 10, 2007 2:50 pm
by JellyFish
How do I execute PHP scripts on my server? What are all the possible ways of doing this? I know that when some one request a php file on my server that it is run. But how do run a php file without the a request from a remote location?
What I would like to do is have a schedule when a file is to be run.
Hopefully you understand what I'm trying to say.
Thanks for reading. All help is appreciated.

Posted: Fri Aug 10, 2007 2:52 pm
by thiscatis
cron jobs?
Posted: Fri Aug 10, 2007 6:37 pm
by JellyFish
thiscatis wrote:cron jobs?
What?
Posted: Fri Aug 10, 2007 7:46 pm
by VladSun
Linux OS:
You can either run:
or include
on the top of your php file. (check the path to php executables!)
make it executable:
and run it:
Posted: Fri Aug 10, 2007 8:50 pm
by John Cartwright
JellyFish wrote:thiscatis wrote:cron jobs?
What?
This is one of those times where it's okay to say
google it
Posted: Fri Aug 10, 2007 9:00 pm
by VladSun
man at
At allows fairly complex time specifications, extending the POSIX.2 standard. It accepts times of the form HH:MM to run a job at a
specific time of day. (If that time is already past, the next day is assumed.) You may also specify midnight, noon, or teatime (4pm)
and you can have a time-of-day suffixed with AM or PM for running in the morning or the evening. You can also say what day the job
will be run, by giving a date in the form month-name day with an optional year, or giving a date of the form MMDDYY or MM/DD/YY or
DD.MM.YY. The specification of a date must follow the specification of the time of day. You can also give times like now + count
time-units, where the time-units can be minutes, hours, days, or weeks and you can tell at to run the job today by suffixing the time
with today and to run the job tomorrow by suffixing the time with tomorrow.
man crontab
crond is responsible for scanning the crontab files and running their commands at the appropriate time. The crontab program communi-
cates with crond through the "cron.update" file which resides in crontabs directory, usually /var/spool/cron/crontabs. This is accom-
plished by appending the filename of the modified or deleted crontab file to "cron.update" which crond then picks up to resynchronize
or remove its internal representation of the file.
Posted: Tue Aug 14, 2007 3:24 pm
by JellyFish
You guys lost me.

Posted: Tue Aug 14, 2007 4:43 pm
by VladSun
Maybe your are asking for this -
viewtopic.php?t=72282
Posted: Wed Aug 15, 2007 5:37 pm
by JellyFish
I'm not really, as I don't understand that post.
I googled Cron and got a bunch of pages I don't understand about it. I'm finding myself not knowing much about servers when that's the guts of a website.
Where's the best place to learn everything there is to know about web servers explained in simple English terms, still explaining server terminology, and how to administrate them?
Posted: Wed Aug 15, 2007 6:05 pm
by VladSun
1. Do you use hosting services or you have your own server?
2. If you use hosting services are you allowed to use SSH?
Posted: Wed Aug 15, 2007 6:12 pm
by JellyFish
VladSun wrote:1. Do you use hosting services or you have your own server?
2. If you use hosting services are you allowed to use SSH?
- I'm on a shared hosting server.
- I don't know. I don't know what SSH is.
Posted: Wed Aug 15, 2007 6:16 pm
by superdezign
JellyFish wrote:
- I'm on a shared hosting server.
- I don't know. I don't know what SSH is.
Shared hosts usually don't offer SSH.
Posted: Wed Aug 15, 2007 6:29 pm
by VladSun
superdezign wrote:Shared hosts usually don't offer SSH.
Hm, in my country SSH is not offered only for the cheapest plan ...
Posted: Wed Aug 15, 2007 6:41 pm
by superdezign
VladSun wrote:superdezign wrote:Shared hosts usually don't offer SSH.
Hm, in my country SSH is not offered only for the cheapest plan ...
Then I've yet to come across the shared host's that do.
Posted: Wed Aug 15, 2007 7:11 pm
by VladSun
A weird solution to your problem is to use exec() and put it in background...
main.php:
Code: Select all
<?php
exec("/usr/local/bin/php -q ".realpath()."/child.php &");
?>
child.php:
Code: Select all
<?php
while (true)
{
// some actions here
sleep(10); // sleep for 10 seconds
}
?>
Then you call the main.php from your browser and close it. The child.php is being executed forever ... I am not sure whether you need to set the maximum execution time of child.php by using
http://www.php.net/set_time_limit with zero argument value .