Ce contenu n'est pas disponible dans la langue sélectionnée.

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.
Retour au début
Red Hat logoGithubredditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance. Découvrez nos récentes mises à jour.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez le Blog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

Theme

© 2025 Red Hat