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 »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • CiviCRM, Drupal and Cron on Windows Server
Pages: [1]

Author Topic: CiviCRM, Drupal and Cron on Windows Server  (Read 529 times)

pmoz

  • I post occasionally
  • **
  • Posts: 101
  • Karma: 2
  • CiviCRM version: 4.4.0, 4.5.3
  • CMS version: Drupal 7.34
  • MySQL version: 5.1.68
  • PHP version: 5.4.9
CiviCRM, Drupal and Cron on Windows Server
September 07, 2014, 07:32:17 am
Holy moley it took me forever to figure out how to get CiviCRM Cron to run in task scheduler!

Maybe it's because I don't use Drush often, maybe it's because not much in this arena is written about functioning on a Windows server.

Anyway, I wanted to pass on how I got CiviCRM Cron to run automatically on Windows Server 2012.
I don't know if this is the best way, but it is what I got to work.

Do all steps on the Windows Server.

Installing necessary software:
Install Drush Windows Installer here:http://www.drush.org/drush_windows_installer.
Make certain that when you install Drush, you install with the Register Environment Variables option.  You need this or else it is more work for you.

Install Git for Windows here: http://msysgit.github.io/.
On the adjusting your path environment page of the GIT install, I selected "Use GIT from the Windows Command Prompt."

Open Git Bash and enter "drush" at the command prompt.
You should get a list of available commands.  That should let you know if everything is functioning correctly.

Create batch file to run CiviCRM:
Now that you've got that stuff installed, you're going to create the batch file to set up in Task Scheduler.

Open Notepad, just regular old Notepad, not Notepad ++ or any fancy pantsy code editor, just old Notepad.
Go to file, save as, change the file type to "All Files" and enter the name of this batch file, I named mine "allcivicrmcronjobs.bat."
Save it to the user folder, so if your uername is Joey, save it to C:\users\joey\

In my case, I wanted to set up all Scheduled CiviCRM Cron jobs so I entered:

c:/ProgramData/Drush/drush -u 1 -r c:/inetpub/wwwroot -l websitename civicrm-api job.execute auth=0 -y

Replace websitename with your domain name, not in italics.  If your Drupal install is in a diferent directory, then you'll need to change that as well.  Just remember that for these programs to recognize spaces in your path, you'll need to surround that part of the path with quotes (example:  c:/inetpub/wwwroot/"my drupal").
Save the bat file and close notepad.

Now if you right click and Run as Administrator on the new batch file, the Cron job should run.  Check if it did on the CiviCRM UI,
Go to CiviCRM, Administer, System Settings, Scheduled Jobs and see if the Last Run time corresponds to your current time.
If those times match up, then the batch file is doing what you wanted.

Set up Task Scheduler:
Open Task Scheduler.
Right Click on Task Scheduler Library and Create Task.
Name it whatever you want.  Name it Doris for all I care.
Add a description.  I like descriptions so actually do this.  "Enter something like Job to run all Scheduled Jobs in CiviCRM."
Select Run whether user is logged on or not and Run with highest privileges.

Click on the Actions tab and New.
Browse to the batch file we just created.  Select it and hit OK.
Review the Triggers, Settings and Conditions tabs and set up however you'd like.
Click on OK and enter your password.  If no warning about permissions came up right click on your new task and select Run to see if the task can run successfully.  If it did, you did it!  Good job.  Time for pizza and a beer.

If after you entered your password you got a warning about permissions, you'll need to poke around your group policy and make sure that the user running the batch file is included in the Log on as batch job permissions.  If you are on a Windows Domain, you'll need to do this on a Domain Controller, if this is a standalone machine you can do it on the local group policy.  When your permissions are correct, the message will go away.
I found this link helpful:
http://social.technet.microsoft.com/Forums/windowsserver/en-US/760ee186-8074-40a5-95b0-35d17c2bdfab/log-on-as-batch-job-right

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • CiviCRM, Drupal and Cron on Windows Server

This forum was archived on 2017-11-26.