Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.

11.13. Scheduling Cron Jobs


Cron jobs for applications are created with the OpenShift Enterprise cron scheduler. This is done by adding the cron scheduler cartridge to an application, adding the required cron jobs to the appropriate directories, and then updating the remote Git repository.
The following instructions describe how to enable cron support for an application. It is assumed the application has already been created.

Procedure 11.4. To Enable Cron Support for an Application:

  1. Add the cron scheduler cartridge to an application:
    $ rhc cartridge add cron -a App_Namerhc cartridge add cron -a App_Name
    Copy to Clipboard Toggle word wrap
  2. Add the cron jobs to the application's .openshift/cron/{minutely,hourly,weekly,daily,monthly}/ directories.

    Example 11.18. Sample Cron File

    $ mkdir -p .openshift/cron/minutely
    $ echo 'date >> $OPENSHIFT_REPO_DIR/php/date.txt' > .openshift/cron/minutely/date.sh
    Copy to Clipboard Toggle word wrap
    The example cron job appends a new line of date information to the $OPENSHIFT_REPO_DIR/php/date.txt file every minute.
  3. Commit the changes and push them to the remote repository:
    $ git add .openshift/cron/
    $ git commit -m "configuring cron jobs"
    $ git push
    Copy to Clipboard Toggle word wrap
Verify that the cron job script you create works correctly.

Example 11.19. Verifying Cron Job Script Works Correctly

For the script used in the example, it can be verified with the following command:
$ curl http://holy-roller.example.com/date.txt
Thu Feb  2 01:02:01 EST 2012
Thu Feb  2 01:03:01 EST 2012
Thu Feb  2 01:04:01 EST 2012
Copy to Clipboard Toggle word wrap
The scripts placed in the /cron subdirectories are executed at the respective frequencies. For example, scripts in each subdirectory are executed in alphabetical order; scripts in the /cron/hourly directory are executed on the first minute of every hour.
Disabling Cron Job Scripts

Disable all cron job scripts with the following command:

$ rhc cartridge stop cron -a App_Namerhc cartridge stop cron -a App_Name
Copy to Clipboard Toggle word wrap

Enabling Cron Job Scripts

Enable all cron job scripts with the following command:

$ rhc cartridge start cron -a App_Namerhc cartridge start cron -a App_Name
Copy to Clipboard Toggle word wrap

Note

The cron commands affect all cron jobs. You cannot disable or enable individual cron jobs.
Nach oben
Red Hat logoGithubredditYoutubeTwitter

Lernen

Testen, kaufen und verkaufen

Communitys

Über Red Hat Dokumentation

Wir helfen Red Hat Benutzern, mit unseren Produkten und Diensten innovativ zu sein und ihre Ziele zu erreichen – mit Inhalten, denen sie vertrauen können. Entdecken Sie unsere neuesten Updates.

Mehr Inklusion in Open Source

Red Hat hat sich verpflichtet, problematische Sprache in unserem Code, unserer Dokumentation und unseren Web-Eigenschaften zu ersetzen. Weitere Einzelheiten finden Sie in Red Hat Blog.

Über Red Hat

Wir liefern gehärtete Lösungen, die es Unternehmen leichter machen, plattform- und umgebungsübergreifend zu arbeiten, vom zentralen Rechenzentrum bis zum Netzwerkrand.

Theme

© 2025 Red Hat