CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • CiviMail installation and configuration (Moderator: Donald Lobo) »
  • Setting up CiviMail Cron Job from a CLI Command Line
Pages: [1]

Author Topic: Setting up CiviMail Cron Job from a CLI Command Line  (Read 2978 times)

enapoleone

  • I’m new here
  • *
  • Posts: 8
  • Karma: 0
  • CiviCRM version: 3.2.5
  • CMS version: Drupal 6.26
  • MySQL version: 5.1.54
  • PHP version: 5.3.5
Setting up CiviMail Cron Job from a CLI Command Line
November 07, 2012, 07:17:08 pm
I'm trying to set up cron jobs for Mailings Scheduler (process_mailings) and Bounces Fetcher (fetch_bounces) I am following the CLI instructions at:

http://wiki.civicrm.org/confluence/display/CRMDOC42/CiviMail+Installation [nofollow]

I'm running CiviCRM 4.1 with Drupal 6.26

My settings file is:

/sites/default/civicrm.settings.php

CiviCRM installation:

/sites/all/modules/civicrm

The first error I encountered was the following:

Could not find valid configuration dir, best guess:  /path/to/website/root/sites/all/modules/civicrm/../../..<br/><br/>
If this is a standalone installation (i.e. not a Drupal or Joomla module) and you'd like to re-initialize it, <a href="../install/index.php?mode=standalone">click here</a>

I thought that I could solve this using the settings_location.php file method however now I'm getting the following error:

Error: Could not create directory: /path/to/website/root/sites/default/files/civicrm/templates_c/en_US/.<p>If you have moved an existing CiviCRM installation from one location or server to another there are several steps you will need to follow. They are detailed on this CiviCRM wiki page - <a href="http://wiki.civicrm.org/confluence/display/CRMDOC/Moving+an+Existing+Installation+to+a+New+Server+or+Location [nofollow]"  target="_blank" title="Opens documentation in a new window.">Moving an Existing Installation to a New Server or Location</a>. A fix for the specific problem that caused this error message to be displayed is to set the value of the config_backend column in the civicrm_domain table to NULL. However we strongly recommend that you review and follow all the steps in that document.</p>

Is this simply a permissions issue? I can not change the permission on my template_c directory because the server requires the ability to write to it.

Cron is running as root.

Do I need to change the permission of a script runs when the cron job executes?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Setting up CiviMail Cron Job from a CLI Command Line
November 07, 2012, 08:09:58 pm

1. are you trying the sscript from the command line? is that when u get the error?

2. r u sure cron is running as root? is your crontab under root?

3. in general if running from cli, it is advisable to give both the apache user and the cli user read/write access to the files/civicrm directory. there are a few different ways of doing this

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

enapoleone

  • I’m new here
  • *
  • Posts: 8
  • Karma: 0
  • CiviCRM version: 3.2.5
  • CMS version: Drupal 6.26
  • MySQL version: 5.1.54
  • PHP version: 5.3.5
Re: Setting up CiviMail Cron Job from a CLI Command Line
November 08, 2012, 06:35:06 am
Hi,

I get the same error when running, as root, from the command line and the error report from cron.

The crontab is edited while as root thus I assume that it runs as root unless I'm mistaken.

Running as root from the command line:

The permissions on files/civicrm are 777 recursively.

path: /sites/all/modules/civicrm
command: php bin/cli.php -j -u username -p password -e Job -a process_mailing

The above username and password being a user in my Drupal system with 'view all contacts', 'access CiviCRM' and 'access CiviMail' permission.

Output:

Error: Could not create directory: /path/to/webroot/sites/default/files/civicrm/templates_c/en_US/.<p>If you have moved an existing CiviCRM installation from one location or server to another there are several steps you will need to follow. They are detailed on this CiviCRM wiki page - <a href="http://wiki.civicrm.org/confluence/display/CRMDOC/Moving+an+Existing+Installation+to+a+New+Server+or+Location"  target="_blank" title="Opens documentation in a new window.">Moving an Existing Installation to a New Server or Location</a>. A fix for the specific problem that caused this error message to be displayed is to set the value of the config_backend column in the civicrm_domain table to NULL. However we strongly recommend that you review and follow all the steps in that document.</p>

I assume that when running the above command as root that the cli has root permission.

Is there something wrong about what I'm doing?

Thanks again.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Setting up CiviMail Cron Job from a CLI Command Line
November 08, 2012, 07:56:52 am
that's a proper path to the right folder?
/path/to/webroot/sites/default/files/civicrm/templates_c/en_US/

Where is your cron? if in /etc/cron.d/ you can set on the first param after the frequency the user to run the cron as (eg. www-data)

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

enapoleone

  • I’m new here
  • *
  • Posts: 8
  • Karma: 0
  • CiviCRM version: 3.2.5
  • CMS version: Drupal 6.26
  • MySQL version: 5.1.54
  • PHP version: 5.3.5
Re: Setting up CiviMail Cron Job from a CLI Command Line
November 08, 2012, 09:29:33 am
Hi Xavier thank you for the idea. However based on what I understood from your reply this is the result.

First, yes this is the proper path:
/path/to/webroot/sites/default/files/civicrm/templates_c/en_US/

I looked in /etc/cron.d/ and should I see a file with the username I'm trying to run cron as i.e. root? Anyway I don't.

Based on what I understood your recommendation was, I edited my crontab and it looks like this:

CIVI_ROOT=/path/to/webroot/sites/all/modules/civicrm/
PHP=nice -n19 /usr/bin/php
PARAMS= -j -s example.com -u username -p password -e Job -a process_mailing
*/5 * * * * apache cd $CIVI_ROOT; $PHP bin/cli.php $PARAMS

My new error is this:

/bin/sh: apache: command not found
Could not open input file: bin/cli.php

It appears to me that it thinks that what I want to use as the USERNAME (apache) is the command.

This is how I understand I should add the USERNAME to the job. Am I making a mistake?

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Setting up CiviMail Cron Job from a CLI Command Line
November 08, 2012, 09:48:51 am
Sorry, don't understand where you put this cron. did you visudo as root?

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

enapoleone

  • I’m new here
  • *
  • Posts: 8
  • Karma: 0
  • CiviCRM version: 3.2.5
  • CMS version: Drupal 6.26
  • MySQL version: 5.1.54
  • PHP version: 5.3.5
Re: Setting up CiviMail Cron Job from a CLI Command Line
November 08, 2012, 09:51:27 am
su root

crontab -e

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Setting up CiviMail Cron Job from a CLI Command Line
November 08, 2012, 10:13:33 am
https://help.ubuntu.com/community/CronHowto

I wouldn't run as root but as the apache user (www-data?)

and definitely something weird that /path/to/webroot/sites/default/files/civicrm/templates_c/en_US/
 is 777 and root can't access it

Not sure what the second is beside telling you to try touching files around in that folder. the first one (using cron.d is more a security issue, but shouldn't make it better to run

Try to run the cron command (bin/cli.php...) manually
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • CiviMail installation and configuration (Moderator: Donald Lobo) »
  • Setting up CiviMail Cron Job from a CLI Command Line

This forum was archived on 2017-11-26.