mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Info about running regular tasks with cron
What commands to use, and good approach to testing
This commit is contained in:
parent
c02d7e4c2e
commit
4db5f75298
@ -124,3 +124,25 @@ 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.
|
||||
|
||||
### 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)
|
||||
|
Loading…
Reference in New Issue
Block a user