Cron does not trigger email notifications script - help
Hi All, I have installed Koha 3.12.01 (by packages) On Ubuntu 12.04.2 LTS server edition. And using postfix to send email notifications (installed using the guide: http://kohageek.blogspot.in/search/label/postfix) and configured with gmail. koha-conf.xml path also has been set properly in both the files. 1) kOHA_CONF=/etc/koha/sites/mvs/koha-conf.xml 2) /usr/share/koha/lib/C4/context .pm I am testing email notifications for every check-in and check-out for patrons. when the script run manually ( ./process_message_queue.pl) , Koha and postfix is able to send mails. but koha cron is not processing respective script on the scheduled time and not delivering emails. cron entry is: # SEND EMAILS 15 * * * * __KOHA_USER__ $KOHA_CRON_PATH/process_message_queue.pl can you please advice me how to fix this? or any other possibilities. thank you in advance. Satish MV Librarian Government Engineering College Hassan - 573 201 Karnataka. --
satish schrieb am 29.06.2013
when the script run manually ( ./process_message_queue.pl) , Koha and postfix is able to send mails.
but koha cron is not processing respective script on the scheduled time and not delivering emails.
Have you tried the packages command to enable emails? Please have a look at http://wiki.koha-community.org/wiki/Commands_provided_by_the_Debian_packages... -- Mirko
Greetings,
koha-conf.xml path also has been set properly in both the files.
1) kOHA_CONF=/etc/koha/sites/mvs/koha-conf.xml 2) /usr/share/koha/lib/C4/context .pm
You shouldn't be editing anything in /usr/share/koha/lib/C4. I am assuming you mean something closer to: KOHA_CONF=/etc/koha/sites/mvs/koha-conf.xml PERL5LIB=/usr/share/koha/lib
when the script run manually ( ./process_message_queue.pl), Koha and postfix is able to send mails.
Good to know.
but koha cron is not processing respective script on the scheduled time and not delivering emails.
Okay, so we know your problem.
cron entry is:
# SEND EMAILS 15 * * * * __KOHA_USER__ $KOHA_CRON_PATH/process_message_queue.pl
I am going to assume that your $KOHA_CRON_PATH is set correctly (something like /usr/share/koha/bin/cronjobs). Okay, you said you used packages. This makes sense, because of your KOHA_CONF setting. In fact, your koha-create command must have created an instance called 'mvs'. We also know that the script you are trying to run is: /usr/share/koha/bin/cronjobs/process_message_queue.pl I seriously doubt you have a user __KOHA_USER__. Though, I suppose that could just be a typo missing a $ in front of it. $ grep koha /etc/passwd library-koha:x:1004:1004:Koha instance library-koha,,,:/var/lib/koha/library:/bin/bash When you run koha-create, you should get an entry in the form of <instance name>-koha added to /etc/passwd. So, I would expect something more like: # SEND EMAILS 15 * * * * mvs-koha $KOHA_CRON_PATH/process_message_queue.pl Though, I would need you to tell me which file you are looking at, so that I can be sure. And lastly, you also should check out what Mirko said. GPML, Mark Tompsett
Thank you Mark and Mirko for your valuable reply. When the message_queue.pl script run manually, I was getting following error previously. root@gechlibrary:/usr/share/koha/bin/cronjobs# ./process_message_queue.pl unable to locate Koha configuration file koha-conf.xml at /usr/share/koha/lib/C4/Context.pm line 375. Can't call method "config" on unblessed reference at /usr/share/koha/lib/C4/Context.pm line 793. at the line no: 192, I modified with proper location of koha-conf.xml loaded. and retried running the script. afterwords, there were no errors. and this is the reason, I edited the file /usr/share/koha/lib/C4/Context.pm And using koha-email-enable instancename option, I did as indicated by Mirko. and when I check, sent notices in the patron screen for emails, it is showing email status: sent and now I believe, cron is doing its work. however, postfix is NOT delivering mails.(SMTP), I am not sure why? ----------------------------------------------------------------------------------------------------------------------------------------------------- and regarding koha user, the output shows as below. root@gechlibrary# grep koha /etc/passwd mvs-koha:x:1001:1001:Koha instance mvs-koha,,,:/var/lib/koha/mvs:/bin/bash the cron entry in /etc/cron.d/koha-common is: /etc/cron.d/koha-common # # Call koha-rebuild-zebra for each enabled Koha instance, to make sure the # Zebra indexes are up to date. SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin */5 * * * * root test -x /usr/sbin/koha-rebuild-zebra && koha-rebuild-zebra $(koha-list --enabled) */15 * * * * root koha-foreach --enabled --email /usr/share/koha/bin/cronjobs/process_message_queue.pl ---------------------------------------------------------------------------------------------------------------------------------------------------------- Thank you in advance. Satish MV Librarian Government Engineering College, Hassan. Karnataka - 573 201 --
On 01/07/13 08:04, satish wrote:
When the message_queue.pl script run manually, I was getting following error previously.
root@gechlibrary:/usr/share/koha/bin/cronjobs# ./process_message_queue.pl unable to locate Koha configuration file koha-conf.xml at /usr/share/koha/lib/C4/Context.pm line 375. Can't call method "config" on unblessed reference at /usr/share/koha/lib/C4/Context.pm line 793.
at the line no: 192, I modified with proper location of koha-conf.xml loaded. and retried running the script. afterwords, there were no errors. and this is the reason, I edited the file /usr/share/koha/lib/C4/Context.pm
That may work, but will be obliterated on the next upgrade and may cause problems if you are serving multiple libraries. The normal way to help scripts locate the configuration file is like this: KOHA_CONF=/path/to/koha-conf.xml ./process_message_queue.pl Hope that helps, -- MJ Ray (slef), member of www.software.coop, a for-more-than-profit co-op http://koha-community.org supporter, web and library systems developer. In My Opinion Only: see http://mjr.towers.org.uk/email.html Available for hire (including development) at http://www.software.coop/
Greetings, Again, don’t edit /usr/share/koha/lib/C4/Context.pm Since your instance name is mvs, I would try something like (no promises this is correct, but the idea is sound as confirmed by MJ Ray’s other email): $ env PERL5LIB=/usr/share/koha/lib KOHA_CONF=/etc/koha/sites/mvs/koha-conf.xml /usr/share/koha/bin/cronjobs/process_message_queue.pl Or why not just set them (this only lasts the current session): $ PERL5LIB=/usr/share/koha/lib $ KOHA_CONF=/etc/koha/sites/mvs/koha-conf.xml $ /usr/share/koha/bin/cronjobs/process_message_queue.pl
root@gechlibrary:/usr/share/koha/bin/cronjobs# ./process_message_queue.pl unable to locate Koha configuration file koha-conf.xml at /usr/share/koha/lib/C4/Context.pm line 375. Can't call method "config" on unblessed reference at /usr/share/koha/lib/C4/Context.pm line 793.
You obviously set PERL5LIB, but not KOHA_CONF, since it found the C4 library. If you have multiple instances, the env method helps prevent confusion as to where your instance’s koha-conf.xml file is. GPML, Mark Tompsett
Op 01/07/13 15:24, Mark Tompsett schreef:
Again, don’t edit /usr/share/koha/lib/C4/Context.pm
This is important. If you're using the packages, everything is set up for you. You don't need to be editing cron jobs or scripts. There are exceptions, but you're likely to know when you need one of those exceptions.
Since your instance name is mvs, I would try something like (no promises this is correct, but the idea is sound as confirmed by MJ Ray’s other email): $ env PERL5LIB=/usr/share/koha/lib KOHA_CONF=/etc/koha/sites/mvs/koha-conf.xml /usr/share/koha/bin/cronjobs/process_message_queue.pl
The env is unnecessary, also you're not accounting for the permissions required to read the koha-conf.xml, so it won't work.
Or why not just set them (this only lasts the current session): $ PERL5LIB=/usr/share/koha/lib $ KOHA_CONF=/etc/koha/sites/mvs/koha-conf.xml $ /usr/share/koha/bin/cronjobs/process_message_queue.pl
This won't work for the same reason, though is an improvement. The best way to do this would be to run: $ sudo koha-shell mvs then your environment is set up, and you don't have to worry about typos or something not working quite right. However, all this is irrelevant to the problem. You (Satish) have identified (probably correctly from what you say) that postfix is the issue. What you need to do is look through the logs (/var/log/mail.info, for example), see a message being sent to postfix by Koha, and then see where it's going from there. Common issues are that you are behind a firewall preventing email going out to the internet. In this case, you'll need to talk to your IT department and get information on the server to relay mail through (often called a smarthost or a relay host.) To configure the simpler aspects of postfix, you can run 'sudo dpkg-reconfigure postfix' and answer the appropriate questions. -- Robin Sheat Catalyst IT Ltd. ✆ +64 4 803 2204 GPG: 5957 6D23 8B16 EFAB FEF8 7175 14D3 6485 A99C EB6D
participants (5)
-
Mark Tompsett -
Mirko -
MJ Ray -
Robin Sheat -
satish