Tos Web Developer provides insights, tutorials, and advice around topics including content strategy, design, Drupal Development, Drupal Custom Module Development, Drupal 8 Custom themes, PHP, Server, Twig, and more



Drupal documentation refers to running cron jobs periodically. But OS X Server (at least Leopard Server) has a kernel bug that results in a log message from cron jobs to the effect “Could not setup Mach task special port 9: (os/kern) no access”. Not a joyful message to come across, though it appears to be harmless.

In addition, OS X doesn’t come with wget, so the suggested cron call in the Drupal docs doesn’t work anyhow.

To avoid both of these problems, put a call to curl in a launchd daemon .plist file (e.g. /Library/LaunchDaemons/drupal-cron-call.plist), thusly:

 <?xml version="1.0" encoding="UTF-8"?>  
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">  
 <plist version="1.0">  
 <dict>  
  <key>Label</key>  
   <string>com.opensocial.drupal-cron</string>  
  <key>UserName</key>  
   <string>nobody</string>  
  <key>GroupName</key>  
   <string>_www</string>  
  <key>ProgramArguments</key>  
   <array>  
    <string>/usr/bin/curl</string>  
    <string>-s</string>  
    <string>http://localhost:8888/opensocial/html/cron/4ns7IESCCWElP5c6xOwZ9EqniA0CidXDbQ-LvvSutTN_0f-CSUrcblELG6BTw4bunAv5fOkQeA</string>  
   </array>  
  <key>RunAtLoad</key>  
   <true/>  
  <key>StartCalendarInterval</key>  
   <dict>  
    <key>StartInterval</key>  
    <integer>60</integer>  
   </dict>  
  </dict>  
 </plist>  

Then Run this CMD
 launchctl load /Library/LaunchDaemons/drupal-cron-call.plist  
Enjoy.

To stop this use this CMD
 launchctl unload /Library/LaunchDaemons/drupal-cron-call.plist  

Notes:
  • For non-production environments, StartCalendarInterval, which always runs at nine minutes past the hour in this example, should perhaps be replaced with StartInterval, which always runs after a specified number of seconds have elapsed (since the last run). For production environments, it’s nice to run cron by the clock, but development computers may be asleep during arbitrary times and thus benefit from the elapsed-time approach. To change this, replace:
  <key>StartCalendarInterval</key>  
   <dict>  
    <key>Minute</key>  
    <integer>09</integer>  
   </dict>  
with:
  <key>StartInterval</key>  
   <integer>3600</integer>  
(This example runs every hour.)

No comments:

Post a Comment

| Designed And Blog Post by www.toswebdeveloper.com