<@ULVA73B9P> I want to delete a schedule in a job....
# marvin-ai
t
@Marvin I want to delete a schedule in a job. I removed the schedule part from prefect.yaml and then i deployed. However the schedule was still there. Is there a way to clear the previous schedules in every deployment so as to keep only the schedule mentioned in the prefect.yaml?
m
thought for 430.3 seconds
Great question. Short answer: removing
schedules:
from
prefect.yaml
and running
prefect deploy
will not delete existing schedules. In Prefect 3.x, schedules are only changed if you explicitly send new schedules; otherwise, existing schedules are retained. Ways to get the behavior you want: - If you want the deployment to have exactly the schedules in your
prefect.yaml
- Keep a
schedules:
section in the YAML with the schedules you want. When present,
prefect deploy
will replace existing schedules with the ones in the file. - Docs: Create deployment schedules, prefect.yaml reference - If you want no schedules (i.e., you removed
schedules:
from the file) - You must explicitly clear them, since
prefect deploy
won’t delete schedules when the section is absent. - Useful commands:
Copy code
# See current schedules
    prefect deployment schedule ls "<flow-name>/<deployment-name>"

    # Clear all schedules
    prefect deployment schedule clear "<flow-name>/<deployment-name>" -y
- CLI reference: Prefect deployment CLI (see the
schedule
subcommands) - If you want to remove one schedule but keep others - List the schedules to get IDs, then delete by ID:
Copy code
prefect deployment schedule ls "<flow-name>/<deployment-name>"
    prefect deployment schedule delete "<flow-name>/<deployment-name>" <schedule-id>
Tip: If you’re automating deployments, you can add a step that runs
prefect deployment schedule clear "<flow>/<deployment>" -y
when your
prefect.yaml
has no
schedules:
section, so the deployment ends up with zero schedules. Would you like me to help craft a small script/CI step that clears schedules when the YAML has none? If you share your deployment name (
<flow-name>/<deployment-name>
), I can give exact commands.
t
@Marvin i am deploying with circle ci using the commands
Copy code
command: |
            uv sync --all-extras
            uv run prefect deploy --all
Is there a command to clear every schedule before deploying and then deploy? So instead of writing every job here do something like:
Copy code
command: |
            uv sync --all-extras
            uv run prefect schedules clear --all
            uv run prefect deploy --all
Is this possible? What do you suggest?
m
thought for 270.1 seconds
You’re on the right track. There isn’t a global “prefect schedules clear --all” command, and
prefect deploy
will not clear schedules when the
schedules:
section is absent. The supported way is per-deployment: - Clear schedules:
prefect deployment schedule clear "<flow>/<deployment>" -y
- Then deploy:
prefect deploy --all
If you truly want to clear schedules for every deployment in the workspace before deploying, you can loop over them. For CircleCI, something like this works:
Copy code
command: |
  uv sync --all-extras
  uv run bash -eo pipefail <<'BASH'
  set -euo pipefail
  # Clear schedules for ALL deployments in the workspace — be careful if you share the workspace!
  mapfile -t deployments < <(prefect deployment ls | awk 'NR>2 {print $1}')
  for d in "${deployments[@]}"; do
    echo "Clearing schedules for $d"
    prefect deployment schedule clear "$d" -y
  done
  BASH

  uv run prefect deploy --all
Safer (recommended) variants: - If your project’s deployments share a naming convention, filter to those:
Copy code
PROJECT_PREFIX="myproject-"   # adjust to your naming scheme
uv run bash -eo pipefail <<'BASH'
set -euo pipefail
prefect deployment ls | awk 'NR>2 {print $1}' | grep "$PROJECT_PREFIX" | xargs -n1 -I{} prefect deployment schedule clear "{}" -y
BASH
uv run prefect deploy --all
- Or explicitly enumerate known deployment names (most robust if you have a short list):
Copy code
DEPLOYMENTS=("flow-a/deploy-a" "flow-b/deploy-b")
uv run bash -eo pipefail <<'BASH'
set -euo pipefail
for d in "${DEPLOYMENTS[@]}"; do
  prefect deployment schedule clear "$d" -y
done
BASH
uv run prefect deploy --all
Notes: - Clearing first is fine: deployments that have schedules in your
prefect.yaml
will recreate them on deploy; those without will remain unscheduled (your goal). - There is no
--all
flag for `prefect deployment schedule clear`; it’s per-deployment. - Verify with:
Copy code
prefect deployment schedule ls "<flow>/<deployment>"
CLI reference for these commands: Prefect deployment CLI (see the
schedule clear
,
schedule ls
,
schedule delete
subcommands). Quick question to tailor the script: do you want to clear schedules for every deployment in the entire workspace, or only for deployments from this repo? If the latter, do your deployment names share a common prefix? I can provide an exact CircleCI snippet based on that.
t
@Marvin if i pause the schedule in the ui and in the next deployment i do not have the schedule section, will then the schedule be cleared?
m
thought for 15.6 seconds
Short answer: No. Pausing a schedule in the UI and then deploying without a
schedules:
section will not clear it. The schedule still exists (and remains paused) because
prefect deploy
only updates schedules if you explicitly provide new ones. To remove schedules, clear them explicitly:
Copy code
prefect deployment schedule clear "<flow-name>/<deployment-name>" -y
Then deploy:
Copy code
prefect deploy --all
If you want deployments to always reflect exactly what’s in
prefect.yaml
, keep a
schedules:
section in the file. When present (and non-empty), Prefect replaces existing schedules with the ones you provide. If you want zero schedules, you must clear them via CLI (an empty
schedules: []
won’t clear). CLI reference: Prefect deployment CLI (see
schedule clear
,
schedule ls
,
schedule delete
).