[Pkg-owncloud-commits] [owncloud-doc] 63/270: add backgroundjobs
David Prévot
taffit at moszumanska.debian.org
Thu Jul 31 03:53:01 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud-doc.
commit 5b4867393f9a7f8bc3fd85a1aad025c326bb474a
Author: Bernhard Posselt <dev at bernhard-posselt.com>
Date: Sun May 11 23:06:18 2014 +0200
add backgroundjobs
---
developer_manual/app/backgroundjobs.rst | 37 ++++++++++++++++++++++++++++++++-
developer_manual/app/info.rst | 2 +-
2 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/developer_manual/app/backgroundjobs.rst b/developer_manual/app/backgroundjobs.rst
index 9875917..49b2629 100644
--- a/developer_manual/app/backgroundjobs.rst
+++ b/developer_manual/app/backgroundjobs.rst
@@ -1,4 +1,39 @@
+======================
Background Jobs (Cron)
======================
-.. sectionauthor:: Bernhard Posselt <dev at bernhard-posselt.com>
\ No newline at end of file
+.. sectionauthor:: Bernhard Posselt <dev at bernhard-posselt.com>
+
+Background/cron jobs are usually registered in the :file:`appinfo/app.php` by using the **addRegularTask** method, the class and the method to run:
+
+.. code-block:: php
+
+ <?php
+ \OCP\Backgroundjob::addRegularTask('\OCA\MyApp\Cron\SomeTask', 'run');
+
+The class for the above example would live in :file:`cron/sometask.php`. Try to keep the method as small as possible because its hard to test static methods. Simply reuse the app container and execute a service that was registered in it.
+
+.. code-block:: php
+
+ <?php
+ namespace OCA\MyApp\Cron;
+
+ use \OCA\MyApp\AppInfo\Application;
+
+ class SomeTask {
+
+ public static function run() {
+ $app = new Application();
+ $container = $app->getContainer();
+ $container->query('SomeService')->run();
+ }
+
+ }
+
+Dont forget to configure the cron service on the server by executing::
+
+ sudo crontab -u http -e
+
+where **http** is your webserver user, and add::
+
+ */15 * * * * php -f /srv/http/owncloud/cron.php
\ No newline at end of file
diff --git a/developer_manual/app/info.rst b/developer_manual/app/info.rst
index 0a58efd..7b06479 100644
--- a/developer_manual/app/info.rst
+++ b/developer_manual/app/info.rst
@@ -30,7 +30,7 @@ The :file:`appinfo/info.xml` contains metadata about the app:
<website>http://www.owncloud.org</website>
- <!-- deprecated -->
+ <!-- deprecated, just for reference -->
<public>
<file id="caldav">appinfo/caldav.php</file>
</public>
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-doc.git
More information about the Pkg-owncloud-commits
mailing list