diff --git a/docs/en/topics/commandline.md b/docs/en/topics/commandline.md index 1b61b5785..b10f35a7e 100644 --- a/docs/en/topics/commandline.md +++ b/docs/en/topics/commandline.md @@ -123,4 +123,26 @@ Step 3: Use sake to start and stop your process Note that sake processes are currently a little brittle, in that the pid and log files are placed in the site root -directory, rather than somewhere sensible like /var/log or /var/run. \ No newline at end of file +directory, rather than somewhere sensible like /var/log or /var/run. + +### Running Regular Tasks With Cron + +On a unix machine, you can typically run a scheduled task with a [cron job](http://en.wikipedia.org/wiki/Cron), +using one of the following command-line calls: + +``` +/path/to/site_root/framework/sake MyTask +php /path/to/site_root/framework/cli-script.php MyTask +``` + +If you find that your cron job appears to be retrieving the login screen, then you may need to use `php-cli` +instead. This is typical of a cPanel-based setup. +``` +php-cli /path/to/site_root/framework/cli-script.php MyTask +``` + +A good approach to setting up and testing your task to run with cron is: + + 1. Try running the task via the command-line on your server. `/path/to/site_root/framework/sake MyTask` + 2. Set up a cron job to run the task every minute. `* * * * * /path/to/site_root/framework/sake MyTask` + 3. Finally, set the task to run when you want it to. `0 2 * * * /path/to/site_root/framework/sake MyTask` (2am)