Page 1 of 1

php cron in code

Posted: Wed Apr 28, 2010 6:18 pm
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

Re: php cron in code

Posted: Wed Apr 28, 2010 6:24 pm
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.

Re: php cron in code

Posted: Wed Apr 28, 2010 6:27 pm
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

Re: php cron in code

Posted: Wed Apr 28, 2010 6:46 pm
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.

Re: php cron in code

Posted: Wed Apr 28, 2010 7:01 pm
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

Re: php cron in code

Posted: Wed Apr 28, 2010 7:25 pm
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.