<@ULVA73B9P> In the `prefect.yaml` file, how do I ...
# ask-marvin
k
@Marvin In the
prefect.yaml
file, how do I specify a cron schedule of
0 6-18 * * 1-5
?
m
To specify a cron schedule in your
prefect.yaml
file, you can follow the example below. This example will schedule your task to run at every hour from 06:00 to 18:00 (inclusive) on weekdays (Monday to Friday).
Copy code
yaml
deployments:
  - name: your-deployment-name
    schedules:
      - cron: "0 6-18 * * 1-5"
        timezone: "UTC"  # You can change the timezone as needed
        active: true
Be sure to fill in
your-deployment-name
with the actual name of your deployment. For more detailed information, you can refer to the Prefect documentation on schedules. Here's a brief example from the documentation:
Copy code
yaml
deployments:
  ...
  schedules:
    - cron: "0 0 * * *"
      timezone: "America/Chicago"
      active: false
    - cron: "0 12 * * *"
      timezone: "America/New_York"
      active: true
    - cron: "0 18 * * *"
      timezone: "Europe/London"
      active: true
This should get you started with scheduling using cron in your
prefect.yaml
file.
k
@Marvin How do I create a deployment from that
.yaml
file?
m
To create a deployment from the
prefect.yaml
file, follow these steps: 1. Ensure you have your
prefect.yaml
file ready
with the deployment configuration, including schedules, like the example below:
Copy code
yaml
deployments:
  - name: your-deployment-name
    schedules:
      - cron: "0 6-18 * * 1-5"
        timezone: "UTC"
        active: true
2. Navigate to the directory containing your
prefect.yaml
file
. You can also initialize your deployment configuration using the CLI command
prefect init
if you need to create a new
prefect.yaml
file. 3. Run the Prefect deployment command to create deployments as specified in the
prefect.yaml
file. Use the following command:
Copy code
sh
prefect deploy -n your-deployment-name
This command will create the deployment based on the information in the
prefect.yaml
file. For further details, you can refer to the Prefect deployment guide. If the
prefect.yaml
file is not in the root of your repository, ensure you provide the correct path to it:
Copy code
sh
prefect deploy -n your-deployment-name -p /path/to/your/prefect.yaml
This should create your deployment successfully.