php cron in code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nite4000
Forum Contributor
Posts: 209
Joined: Sun Apr 12, 2009 11:31 am

php cron in code

Post by nite4000 »

Hey All,

I am in need of some hard php help. I need to basically do a cron job WITHOUT setting up a cron throug cpanel.

To give example

I will need it to update or run every hour,daily,weekly and so on.
it would update a table in the db so would have to be a page alone to update the table.

I know how to do this via cron job but i need to do this without setting up in cpanel. i know it can be done.

I was told to use a function to count but Not sure how to get started. If someone could get me going with the hourly and daily thing I could take it from there.

Thanks
Don
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: php cron in code

Post by califdon »

The only way to do that would be to have a PHP function in a continuous loop, that is, constantly running. That's a HORRIBLE idea and no hosting service in their right mind would allow you to do that.
nite4000
Forum Contributor
Posts: 209
Joined: Sun Apr 12, 2009 11:31 am

Re: php cron in code

Post by nite4000 »

So you would suggest that I set up each cron job? but here is the thing i was trying to avoid. If I was to sell the script I do not want to have to make them set up the cron jobs.

You have any other suggestions?


Thanks
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: php cron in code

Post by califdon »

Wow, if you sold a script that constantly ran in their server, they would probably sue you! The ONLY acceptable way to execute a job on an automatic time-based schedule is to use the scheduler the OS provides--for Linux, that's cron; for Windows its the Scheduler. What is it that you are doing? Although there are, surely, some valid rationales for updating a database on a timed schedule, it has been my experience that 9 out of 10 questions on this subject are completely confused, to begin with. Very few database applications should need to be updated when nobody is accessing the database.
nite4000
Forum Contributor
Posts: 209
Joined: Sun Apr 12, 2009 11:31 am

Re: php cron in code

Post by nite4000 »

I cant give out what I am doing. Its nothing illegal but I am not able to say. if it ran like that then NO ONE would sue me as I have my own servers. but thanks for your non suggestions.

Thanks
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: php cron in code

Post by califdon »

nite4000 wrote:I cant give out what I am doing. Its nothing illegal but I am not able to say. if it ran like that then NO ONE would sue me as I have my own servers. but thanks for your non suggestions.

Thanks
I don't think you understood me. If you sell a script that requires repetitive execution and the purchaser runs that script, it would be running on THEIR server. If it runs on YOUR server, you wouldn't be selling a script to anybody else, since PHP only runs on a web server.
Post Reply