Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Issues With Cron and Catalog price rules
 
Loic_LC
Sr. Member
 
Avatar
Total Posts:  194
Joined:  2007-12-19
Paris, France
 

Do you have access to your myphpadmin ? most likely from you cpanel.
if you don’t know these you might want to ask your host.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Revilo
Member
 
Avatar
Total Posts:  68
Joined:  2009-03-19
 

sorry guys been pretty busy.

i will have to look into your problem Loïc but i am sure it is in a xml file, i just have to remember where it is. Have you found it?

Yes it should have a ?> at the end of the file. must of missed it in the copy paste. For the life of me i was unable to work out the database login/pass from the magento installation. It is hidden some where but i do not have an answer. If possible check you cPanel or plesk install database util and see if it is located in there.

Cheers
Revilo

 
Magento Community Magento Community
Magento Community
Magento Community
 
Revilo
Member
 
Avatar
Total Posts:  68
Joined:  2009-03-19
 

ok if you go to http://www.magentocommerce.com/wiki/how_to/how_to_setup_a_cron_job it shows you how to edit a job for display.

app/code/core/Mage/CatalogRule/etc/config.xml:

find

#
    <crontab>
#
        
<jobs>
#
            
<catalogrule_apply_all>
#
                
<schedule><cron_expr>0 1 * * *</cron_expr></schedule>
#
                
<run><model>catalogrule/observer::dailyCatalogUpdate</model></run>
#
            
</catalogrule_apply_all>
#
        
</jobs>
#
...
#
    
</crontab>

and edit the <cron_expr>0 1 * * *</cron_expr> as per cron syntax basicly this will set of the job everyday @ 0100

when i go to app/code/core/Mage/Sitemap/etc/config.xml:

and go to the cron tab the <schedule> part is missing above the run. Maybe try coping the above<schedule> section and pasting it into your app/code/core/Mage/Sitemap/etc/config.xml file, before the <run> tag, and see if that works. Sorry i am unable to test this as i only have a live production environment atm. Good luck!

 
Magento Community Magento Community
Magento Community
Magento Community
 
cheekygeek
Jr. Member
 
Total Posts:  30
Joined:  2009-04-14
 

I got my cron working properly and the problem was not with Magento but hosting-installation related. Other people may be in my same boat, so read on.

The short story is this: I used SimpleScripts (available in my cPanel from Bluehost) to install Magento. It is really a nice painless way to get up and running. I do upgrades through the SimpleScripts interface also (not through Magento Connect). Anyway, when I went into my cPanel cron section, I saw that SimpleScripts had already configured a call to the Magento cron.php file. The problem was that it didn’t work. All of the information for fixing it is earlier in this thread (great work Revilo!)

You can test whether your cron works by:
a) putting the code to email you when “it’s working” at the bottom of your cron.php file (see Revilo’s post on page 1 of this thread). While you are at it, make sure you have a closing PHP tag at the end of your cron.php file. I didn’t! It looks like this:
?>

b) go into your cPanel “Cron Jobs” and change the cron.php line to this:

ramdisk/bin/php5 /home/YourUserNameOrDomain/public_html/cron.php >> /dev/null 2>&1;(Notice we have removed the deprecated -f flag and put the full path to the cron.php (which the SimpleScripts line did not do). - Revilo pointed this out on Page 1 of this thread, as well.
Change the interval that the Cron Job runs to whatever you want. I made it 5 minutes to begin with and then once I was sure it was working went back in and backed it off to a more infrequent time.

c) optional, but nice: the cronmon.php file (also provided by Magento User of the Month Revilo) lets you see what is being run and what has been run. You need to input your database information in the first lines of the cronmon.php file (as Revilo stated earlier). Putting “localhost” as the database value worked in my case. Upload the cronmon.php to your root folder and call it with your web browser (http://www.yourdomain.com/cronmon.php )

Bob’s your uncle.

I’m looking into Revilo’s last post about the config.xml next. I don’t quite understand why we need crontab information here AND on the server, but I’ll read up on it.

Thanks again to Revilo for all his help in this thread! Just thought I’d pass along what works for me

 
Magento Community Magento Community
Magento Community
Magento Community
 
Revilo
Member
 
Avatar
Total Posts:  68
Joined:  2009-03-19
 
cheekygeek - 30 September 2009 05:15 AM

I’m looking into Revilo’s last post about the config.xml next. I don’t quite understand why we need crontab information here AND on the server, but I’ll read up on it.
Thanks again to Revilo for all his help in this thread! Just thought I’d pass along what works for me

Cheers I appreciate the feedback. The xml file mentioned above is for each individual cron job that magento runs eg newsletter send, catalog index etc.

the code post on page one has the ?>

Cheers

 
Magento Community Magento Community
Magento Community
Magento Community
 
Nick Rigby
Member
 
Total Posts:  57
Joined:  2007-09-03
 

Hey Revilo, thanks for all the information you have given in this post. I managed to get cron working with all this help!

Quick question… is it normal for there to be multiple instances of scheduled tasks in the pending jobs section? Every time my cron runs (every 5 minutes) it seems to schedule the following to run 5 times each:

newsletter_send_all
catalogindex_run_queued

Thanks,
Nick.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Revilo
Member
 
Avatar
Total Posts:  68
Joined:  2009-03-19
 
Nick Rigby - 03 October 2009 07:26 AM

Hey Revilo, thanks for all the information you have given in this post. I managed to get cron working with all this help!

Quick question… is it normal for there to be multiple instances of scheduled tasks in the pending jobs section? Every time my cron runs (every 5 minutes) it seems to schedule the following to run 5 times each:

newsletter_send_all
catalogindex_run_queued

Thanks,
Nick.

Thanks Nick I appreciate the positive response.

If you take a look at your cron jobs you will see that they are in 1 minute intervals. Being that the actual cron executes every 5 minutes 5 of each of those jobs gets added. Short answer, yes that is normal.

Cheers
Revilo

 
Magento Community Magento Community
Magento Community
Magento Community
 
Nick Rigby
Member
 
Total Posts:  57
Joined:  2007-09-03
 

Thanks Revilo! It made sense shortly after I had posted, since the default Magento setting for those two items is set to run every minute, of every hour of every day etc. Thanks again for your info though, as I’ve been trying to get cron working for a long time now!

Thanks,
Nick.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Revilo
Member
 
Avatar
Total Posts:  68
Joined:  2009-03-19
 

Thanks Nick, glad to help.

 
Magento Community Magento Community
Magento Community
Magento Community
 
gfawce1
Member
 
Total Posts:  31
Joined:  2008-11-15
 

Hi all…

This post tipped me off to the fact that I was doing something quite stupid and it ended up being the reason why my cron jobs weren’t working…

Although my server runs php5 it doesn’t run the minimum version required to run magento so I’m using the php5 binary supplied by Magento. My cron command used to look like this:

/usr/loca/php -/var/www/vhosts/mydomain.com/httpodcs/cron.php

Didn’t work. Now it looks like this:

/var/www/vhosts/mydomain.com/cgi-bin/php5-cgi -/var/www/vhosts/mydomain.com/httpodcs/cron.php

Working perfectly! D’oh!

Thanks guys!

 
Magento Community Magento Community
Magento Community
Magento Community
 
MaxOnTheHill
Member
 
Avatar
Total Posts:  56
Joined:  2009-04-10
Olinda, Victoria, Australi
 

Hi All - I have been trying to get a good easy and “logical” fix to this issue for a little while and looking around I think I’ve found a very quick and easy fix that is atleast working for me and ensures that my catalogue price rules are ALWAYS working OK and do not (noticiably) disappear.

In the file:
app/code/core/Mage/CatalogRule/etc/config.xml

Change the code

<crontab>
        <
jobs>
            <
catalogrule_apply_all>
                <
schedule><cron_expr>0 1 * * *</cron_expr></schedule>
                <
run><model>catalogrule/observer::dailyCatalogUpdate</model></run>
            </
catalogrule_apply_all>
        </
jobs>
        <
events>
            <
catalog_product_get_final_price>
                <
observers>
                    <
catalogrule>
                        <
type>singleton</type>
                        <class>
catalogrule/observer</class>
                        <
method>processAdminFinalPrice</method>
                    </
catalogrule>
                </
observers>
            </
catalog_product_get_final_price>
        </
events>
    </
crontab>

to

<crontab>
        <
jobs>
            <
catalogrule_apply_all>
                <
schedule><cron_expr>0 1 * * *</cron_expr></schedule>
                <
run><model>catalogrule/observer::dailyCatalogUpdate</model></run>
            </
catalogrule_apply_all>
            <
catalogrule_apply_pricingrules>
                <
schedule><cron_expr>0 1 * * *</cron_expr></schedule>
                <
run><model>catalogrule/observer::applyAllRules</model></run>
            </
catalogrule_apply_pricingrules>            
        </
jobs>
        <
events>
            <
catalog_product_get_final_price>
                <
observers>
                    <
catalogrule>
                        <
type>singleton</type>
                        <class>
catalogrule/observer</class>
                        <
method>processAdminFinalPrice</method>
                    </
catalogrule>
                </
observers>
            </
catalog_product_get_final_price>
            <
catalog_product_get_front_price>
                <
observers>
                    <
catalogrule>
                        <
type>singleton</type>
                        <class>
catalogrule/observer</class>
                        <
method>processFrontFinalPrice</method>
                    </
catalogrule>
                </
observers>
            </
catalog_product_get_front_price>            
        </
events>
    </
crontab>

All fixed - has been going like this for a couple off days and have not had to reset price rules since - ABOUT TIME!!!  wink

Hope this helps someone, Max.

 
Magento Community Magento Community
Magento Community
Magento Community
 
MaxOnTheHill
Member
 
Avatar
Total Posts:  56
Joined:  2009-04-10
Olinda, Victoria, Australi
 

ohh . . . and just in case you are interested the reference for the code syntax is at:

http://docs.magentocommerce.com/Mage_CatalogRule/Mage_CatalogRule_Model_Observer.html

this docs can somtimes be REALLY helpful.

----------
hmmm . . . didn’t update price rules last night changed, see if the timing fixes the issue:

<catalogrule_apply_pricingrules>
                <
schedule><cron_expr>0 2 * * *</cron_expr></schedule>
                <
run><model>catalogrule/observer::applyAllRules</model></run>
            </
catalogrule_apply_pricingrules>
 
Magento Community Magento Community
Magento Community
Magento Community
 
Revilo
Member
 
Avatar
Total Posts:  68
Joined:  2009-03-19
 

Nice Max. Is your cron working though?

 
Magento Community Magento Community
Magento Community
Magento Community
 
MaxOnTheHill
Member
 
Avatar
Total Posts:  56
Joined:  2009-04-10
Olinda, Victoria, Australi
 

Hey Revilo,

I beleive the cron is working (set to run every hour from cPanel).  The command I am running was advised by my host (Rochen) so that it would execute correctly:  php /home/wholesal/public_html/cron.php and I assume it is working OK

In the email from the cron that gets sent to me every hour I get the message
“X-Powered-By: PHP/5.2.10 Content-type: text/html done!” , the ‘done!’ message was added to cron.php by myself a while back after following another thread about cron issues.

I’ll report back on whether the timing change above actually fixes the price problem, or whether the price rules still turn off . . .frustrating issue this!

 
Magento Community Magento Community
Magento Community
Magento Community
 
krisb78
Jr. Member
 
Total Posts:  13
Joined:  2009-05-25
 

Hi there,

First of all, a big thanks to the previous posters (especially Revilo) for helping me getting Cron to work. Using a combination of the tips here mine now functions.

I thought I might let you all know what worked for me. This is my setup:

Shared hosting on Bluehost.
Original Magento installation (1.3.2.1) done using Simple Scripts but all following upgrades done using Magento Connect to current 1.3.2.4.
cPanel control
php version 5.2.9

Cron job syntax - the only way I could get this to work was using: “wget http://store.mydomain.co.uk/cron.php > /dev/null”
I tried every other combination here and would just get errors (either the cronjob wizard on bluehost would not accept it or the confirmation email from bluehost for each cron job would report numerous errors).

I used Revilo’s modified cron.php file (with the corrected “?>” at the end). I also used the cronmon.php file. One thing I did notice that before modifiying cron.php, if I tried to run it directly from my browser (ie just by typing in http://mydomain.co.uk/cron.php) I would get a 500 sever error and the server would actually change the file permissions on the file. I would then have to manually go through cPanel to reset it. This doesn’t appear to happen now.

Lets hope it keeps working and that my Catalog Price Rule Promotions keep working overnight (the reason I had to go through all this in the first place!!)

Thanks again,

Kris.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top