How can I get cron jobs to run automatically
drupalina - September 28, 2007 - 16:16
Hello,
So far I'm running cron jobs mannually. And it is quite time consuming because I have other things to do than run cron every 2 hours. I read the handbooks on cron configurations, but didn't get much, since I'm not a PHP literate person.
How can I make my drupal run cron automatically??? So that I don't have to come back to my site every 2 hours.
I have noticed that there are 2 modules that could potentially help:
Cron Plus http://drupal.org/project/cronplus
and
Poor Man's Cron http://drupal.org/project/poormanscron
any suggestions on what to do? Which one of these 2 shall I choose? Is there a better cron module?
please help.... thank you in advance

cron on server
the best would be to get your hosting company to setup a cron for you. That will make sure that you or another person does not have to visit the site to get poormanscron to run.
Need more info
Like aufumy says, the solution to your problem depends on the options provided by your web hosting service. Do you have shell access? Are you limited to managing your account via cPanel? You usually don't need a module to set up the basic cron task, but you'll have to provide a few details to get a specific solution.
www.roopletheme.com
I'm with hostmonster
thank you roopletheme.
I'm with Hostmonster --- I don't know if I have access to shell, but I know that Hostmonster provides a lot of access to many things that other don't. If you go to http://hostmoster.com/ and click "Hosting features" you will be able to see what access I get.
I spoke to hostmonster support and they said that I will need to write some PHP script to get the crons to run automatically. But I don't know anything about PHP (I just use drupal and modules as they come out of the box. I mean I want to create a custom front page for the FrontPage module and I don't even know how to do that). They also said that I could get crons to run from within their Control Panel -- but they were not sure if this is the best thing for Drupal and advised me to speak to Drupal community instead.
Will "Poor Man's Cron" module do the job?
(Quite frankly even after reading the handbook pages, I'm stil not quite clear what on earth cron is. I know that it is a set of tasks that need to run every now and then. But I noticed that once a new user registers he will not be able to find his hame in the searches unless I run cron. I have been going to Admin >>Logs>> Status Report >> Run cron manually for the past 3 months every 2-3 hours without knowing why... have you seen "LOST"??? It's like entering those number withought not knowing why ;)
poormanscron
if your needs are simple and confined to drupal (indexing, aggregator, etc.), it works just fine. you can have it log to watchdog, if you are unsure if it is running or not.
"cron" is a scheduling service; microsoft's "at"/"scheduled tasks" is a poor imitation. look it up in wikipedia, if you want a brief overview.
I have the poormanscron
I have the poormanscron module and I'm completely satisfied. It does all the cron jobs exactly when I programmed it to run.
http://www.dobro.gr - Online community for Greek students in Bulgaria
http://virgus.no-ip.org - simple designs
Maybe this will work
Looks like Hostmonster gives you a lot of options. Try this for starters. Go to your website control panel (www.yoursite.com/cpanel), scroll down the page to the 'Advanced' group, and click on the 'Cron Jobs' icon. Next, click on the 'Advanced tab' and you'll get an opportunity to create new cron job entries. You want to change the asterisk in the 'hours field' to '*/2', change the 'command' field to something like '/usr/bin/php -q /home/youraccountname/public_html/cron.php', and then click 'Commit Changes'. This should get your cron jobs running every two hours.
You might need to make adjustments to the command to accommodate differences in your hosting service, but this should get you going in the right direction.
Hope this helps.
www.roopletheme.com
Thank you for an elaborate
Thank you for an elaborate reply. Really appreciate it. I tried to do what you said but it was a bit over my head, though I could give it another go...
I'm wondering why do you think doing it this way is better than just simply installing PoorMansCron module???
(my website is still quite small, but it is slowly growing. It has strong social-networking features (buddylist, private messaging, events, groups, invite etc. Of course when the traffic increases, I'm going to move the site to a proper dedicated server. But I'm wondering if having PoorMansCron will suffice to deal with a site that could be getting 10,000 hits per day or maybe even more. )
Shall I install PoorMans Cron or shall I try again to do it through the CPanel?
Poormanscron vs. system cron
Hi drupalina,
Poormancron is as the name indicates a poor mans solution meaning if you can't hook into the system cron this will do the job but not as efficiently.
Poormanscron executes at every page load and if there are any cron jobs in the que (aggregator: fetch feeds, search: index new posts, ...) they will be executed. Since this is on pageload as in when a user visits a page this will add to the time it takes for the user to get the page. It also means that the cron is only runs if someone is actually visiting the site.
The system cron is part of the server, not Drupal. Setting it up as roopletheme describes means the server will execute Drupals cron.php once every two hours. No user interaction on the site is needed, no direct impact on pageload compared to Poormanscron.
You may want to increase the frequency though depending on how often new content is added to the site as the search module only indexes new content when cron is run.
Read the install.txt file, specifically the section about installation, subsection 5 called "CRON TASKS". It is in the root of your Drupal installation.
Also the handbooks are your friends. Have a look at the "The Drupal Cookbook (for beginners)" specifically section "M. Setting Up Cron".
To answer your question about which road to take I would say both for starters ...
Install Poormanscron so your site has a fairly regular run of cron. Then read up on how to setup system cron via cpanel and give it a try. Look in watchdog to see if system cron is running as it should. It identifies it self as "cron" while poormanscron uses ... well ... "poormanscron" :-). When you are satisfied with the system cron setup you can deactivate Poormanscron and uninstall it.
On a side note ... CronPlus is an API for other modules to implement a more fine grained scheduling so it will not help you here.
Regards,
Christian Larsen
it's very easy
Hi drupalina. I hope you managed to set up cron jobs with cpanel . if you 're still having problems, I will try to explain step by step.
"How to set up cron Jobs on Hostmonster"?
step 1: - Go to your Control Panel (Cpanel)
step2: - Go to "Advanced" tab of your Control Panel, where you see "cron jobs" icon.
step 3.- click on cron jobs icon (calendar like)
step 4: you will see 2 buttons: "Standard" and "Advanced (Unix Style)"- Click on "Standard" button!
step 5: You have to insert a command; Now let's say your have domain name: www.dddrupal.com+ and your hostmonster login let's say is "drupe0".
IF!!! www.dddrupal.com is your main Domain on hostmonster then command will be this: php /home/drupe0/public_html/cron.php
----
If www.dddrupal.com is NOT a main domain, the command will look
like this: php /home/drupe0/public_html/dddrupal/cron.php
-------------------------
note if you write a command with "php" sticked to slash it won't work!!
like this php/home/drupe0/.... (no good)
give a space after "php" like this: php /home/drupe0/ ..... (good:)
---------------------
step 6: just choose cron jobs run time period (2 hours/every day...etc);
step7: CLICK "Save crontab" button
You're done now, you can check you drupal site's "status report", where you will find out that cron jobs have been set.
sorry for long story, but this step by step guide is also for future users having similar problems.
good luck
Thanks for this detailed
Thanks for this detailed guide. My host also uses CPanel and the same steps are available there. This should be made a part of the beginner's guide to set-up cron.
thanks
I second the opinion expressed that this be made a part of the beginner's guide. Excellent explanation. Had a tough time trying to find the right command.
Bhambry