Koozali.org: home of the SME Server

Using cron to run a php file

Offline animare

  • *
  • 29
  • +0/-0
Using cron to run a php file
« on: September 28, 2012, 01:36:19 PM »
Hi,

I run man drupal sites using the sme server and I would like to run a cron.php file.
I am using webmin to create a scheduled cron job.
I can successfully run the cron job using wget and a url pointing to the cron file.
But I really want to run the cron file locally. i.e.
/home/e-smith/files/ibays/drupalsite/html/cron.php

I have tried many ways but none seem to work. e.g :
/usr/bin/php /home/e-smith/files/ibays/drupalsite/html/cron.php
php /home/e-smith/files/ibays/drupalsite/html/cron.php

etc.

Any help would be great!

Thanks

Apologies if posting this in the wrong place.

Offline mmccarn

  • *
  • 2,626
  • +10/-0
Re: Using cron to run a php file
« Reply #1 on: September 28, 2012, 01:53:48 PM »
My crontab (login as root; crontab -e) uses a cd command before running a local php, like this:
Code: [Select]
*    *    *    *    *     cd /home/e-smith/files/ibays/sugarcrm/html; php -f cron.php > /dev/null 2>&1
However, I don't think I ever got local php execution working for Drupal, so my crontab line for that looks like this:
Code: [Select]
45   *    *    *    *     /usr/bin/wget -O - -q -t 1 --no-check-certificate https://mind.yourown.biz/cron.php?cron_key=jpGWAhDarVIgareyoukiddingpGgK54wMwSBsKRpZsY > /dev/null 2>&1

Offline animare

  • *
  • 29
  • +0/-0
Re: Using cron to run a php file
« Reply #2 on: September 28, 2012, 02:00:13 PM »
Thanks,

That first command didn't work for drupal, I'm going to keep trying till I find a way!
I'll post back if I figure it out

Offline animare

  • *
  • 29
  • +0/-0
Re: Using cron to run a php file
« Reply #3 on: September 28, 2012, 02:37:48 PM »
I think I'm trying to do something that cannot be done in sme server.
Drupal docs says that using wget is the recommended way anyway so I'm probably just wasting time.

Thanks again

Offline animare

  • *
  • 29
  • +0/-0
Re: Using cron to run a php file
« Reply #4 on: September 29, 2012, 02:19:19 PM »
I figured out how to do it:

Code: [Select]
/usr/bin/drush -r /home/e-smith/files/ibays/d7anim/html cron > /dev/null 2>&1
You must have drush installed on your server. But it is very easy to install.
I think it is much better to run cron locally, especially if you have your ibay locked down with password (Or you use a .htacesss file)