To have your mailing actually send. We have to set up a cron job that will periodically poke CiviMail to send all of the mailings that are past their scheduled date.
Actually there are so many ways out there to do this thing, and probably are shorter, but I’ve built a script for my self to do that for me and is more clear to understand.
Note: The script works only with Drupal.
1. Create a file in /usr/local/bin/ called civicrmcron.sh
and add the following lines in it, edit the required fields and save it:
#!/bin/sh ######################################################################################## # # This script pokes CiviMail to send all the mailings that are past their schedule date. # Make this script executable. # Run this script from cron every 1 minute or every second (as you want). # This script works only with Drupal. # This script is tested and works... # ######################################################################################## ############################# EDIT ONLY THESE LINES #################################### # # Drupal user (Note: this user should have rights to work on CiviCRM) # drupalUser='USER' # # Drupal user's password # drupalUserPass='PASSWORD' # # Drupal/Civicrm site-key # You can take it from: /sites/default/civicrm.settings.php # on line: # define( 'CIVICRM_SITE_KEY', 'SITE-KEY-HERE' ); # civicrmSiteKey='SITE-KEY' # # Write sitename here in this case example: civicrm.example.com # siteName='civicrm.example.com' ############################################################################ civiurl="http://$siteName/sites/all/modules/civicrm/bin/civimail.cronjob.php" echo '' echo 'Your civimail.cronjob.php file is here: ' echo $civiurl echo "Gathering your data..." cividata="name=${drupalUser}&pass=${drupalUserPass}&key=${civicrmSiteKey}" #echo $cividata # Grouping all data in one place... echo 'Grouping all data in one place ...' allurl=$civiurl'?'$cividata # Running the script... echo 'Running the script...' #echo "wget -O - -q $allurl" # Executing the script wget -O - -q $allurl sleep 1 echo '' echo "DONE !" echo ''
2. After that change permissions to this file to a+x or +x
$ sudo chmod +x /usr/local/bin/civicrmcron.sh
3. Then create a file in /etc/cron.d named civicrm
$ sudo nano /etc/cron.d/civicrm
add the lines below lines to run the job every 5 minutes and save:
*/5 * * * * root /usr/local/bin/civicrmcron.sh > /dev/null
Thanks for this amazing script. I think this is the easiest option. However, i have a few questions:
1. How do i locate /usr/local/bin/
2. How do i locate /etc
Hi,
I was using a localserver running Linux, so those are directories in my server.
I am sorry if you are using Windows, unfortunately I don’t know how it is done there so I cannot helo you on windows
You really make it seem so easy with your presentation
but I find this matter to be really something that I think
I would never understand. It seems too complicated and very broad
for me. I’m looking forward for your next post, I will try to get the hang of it!
http://www.easycron.com provides online cron job service. It’s an alternative to task scheduler solution under Windows & Linux.