如何在OpenShift Container Platform中创建、查看与管理CronJob?
Hey there! I totally get that it can be tricky to find where to manage CronJobs in OpenShift once you’ve created them via YAML. Let’s break down how to view, edit, and delete your CronJob using both the web console and the oc command line tool:
Viewing Your CronJob
Via the Web Console
- Log into your OpenShift Container Platform web console.
- Select your target project from the project dropdown at the top of the page.
- On the left-hand navigation menu, expand the Workloads section (if it’s collapsed) and click on CronJobs. You’ll see all CronJobs in your project listed here.
- Click on the name of your CronJob to open its details page, where you can check its schedule, last run time, associated Job history, and configuration details.
Via the oc Command Line
- To list all CronJobs in your project:
oc get cronjobs # Or use the shorthand "cj": oc get cj - To view detailed information about a specific CronJob:
oc describe cronjob <your-cronjob-name> # Shorthand version: oc describe cj <your-cronjob-name>
Editing Your CronJob
Via the Web Console
- Go to the CronJobs list page (as outlined in the viewing section) and click on your CronJob’s name to open its details.
- In the top-right corner, you’ll see two options for editing:
- Edit: Opens a form-based interface where you can adjust basic settings like the schedule, container image, resource limits, and more.
- Edit YAML: Lets you directly modify the full YAML configuration of the CronJob. Make your changes, then click Save to apply them.
- Note: Any changes you make will take effect immediately for future scheduled runs.
Via the oc Command Line
- To edit the CronJob directly in your default terminal editor:
Save your changes and exit the editor—OpenShift will automatically apply the updated configuration.oc edit cronjob <your-cronjob-name> # Shorthand: oc edit cj <your-cronjob-name> - If you have a modified YAML file locally, you can apply it with:
oc apply -f <path-to-updated-cronjob.yaml>
Deleting Your CronJob
Via the Web Console
- From the CronJobs list page, find your CronJob. Click the three-dot menu (⋮) on the right side of its row, then select Delete.
- Confirm the deletion in the pop-up window, and the CronJob will be removed (along with any associated Jobs that aren’t set to persist).
- Alternatively, you can click the Delete button in the top-right corner of the CronJob’s details page.
Via the oc Command Line
- To delete the CronJob immediately:
oc delete cronjob <your-cronjob-name> # Shorthand: oc delete cj <your-cronjob-name>
内容的提问来源于stack exchange,提问作者Relinwar
相关产品推荐
相关产品推荐

