OM2 Posted July 24, 2008 Share Posted July 24, 2008 How much CPU and/or memory does running a cron job take? OK: like asking how long a piece of string is...? I need to write some code that access an API and updates an XML file. This should happen every 12 hours, lets just assume. One cron job, I assume not a problem at all. But... I'm building a website where there could be 5000 members. Now, let's say each of the members needs to have the same cron job run. NOW is it more significant? Would it be a good idea to maybe run the cron job on another server and then simply access the same files on this other server? Thanks. OM Quote Link to comment https://forums.phpfreaks.com/topic/116328-how-much-cpu-andor-memory-does-running-a-cron-job-take/ Share on other sites More sharing options...
trq Posted July 24, 2008 Share Posted July 24, 2008 Cron itself takes up very little cpu, it depends on the scripts you ask it to execute. For that I'm afraid, there is simply no definitive answer. Now, let's say each of the members needs to have the same cron job run. That would seem rediculous, design your script in such a way that it should be abble to do whatever it needs to do for all 5000 users in one hit. Quote Link to comment https://forums.phpfreaks.com/topic/116328-how-much-cpu-andor-memory-does-running-a-cron-job-take/#findComment-598142 Share on other sites More sharing options...
tibberous Posted July 24, 2008 Share Posted July 24, 2008 Thorpe is right, why would you have 500 different cron scripts when you could have one script process 500 users. Use set_time_limit if you think whatever your going to do will exceed a few minutes. Quote Link to comment https://forums.phpfreaks.com/topic/116328-how-much-cpu-andor-memory-does-running-a-cron-job-take/#findComment-598146 Share on other sites More sharing options...
trq Posted July 24, 2008 Share Posted July 24, 2008 Use set_time_limit if you think whatever your going to do will exceed a few minutes. set_time_limit is already set to 0 by default in regard to the php-cli. And if your running php scripts through cronjobs, there really isn't much point requesting them through apache. Quote Link to comment https://forums.phpfreaks.com/topic/116328-how-much-cpu-andor-memory-does-running-a-cron-job-take/#findComment-598149 Share on other sites More sharing options...
tibberous Posted July 24, 2008 Share Posted July 24, 2008 I've had CLI scripts give 'max time exceeded' - it might just be how my host had it setup, but it still might be good not to take it for granted. Quote Link to comment https://forums.phpfreaks.com/topic/116328-how-much-cpu-andor-memory-does-running-a-cron-job-take/#findComment-598340 Share on other sites More sharing options...
OM2 Posted July 24, 2008 Author Share Posted July 24, 2008 guys: thanks for the replies. it does need to be 5000 seperate calls. each user will need to pull in different data. 5000 is an extreme: if i get to that number, i'll happily invest a lot of money in having several dedicated servers! the bit where u said cron jobs dont use much resources on their own - its more the actual task... that answered what i needed to know. thanks. Quote Link to comment https://forums.phpfreaks.com/topic/116328-how-much-cpu-andor-memory-does-running-a-cron-job-take/#findComment-598511 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.