<@ULVA73B9P> how to use prefect cli
# ask-marvin
s
@Marvin how to use prefect cli
m
The Prefect CLI allows you to interact with your Prefect environment directly from your terminal. Here's a quick overview on how to use Prefect CLI to manage and execute tasks. ### Commonly Used Commands For Prefect 2.x and 3.x Series: -
prefect shell serve
: This command helps to run shell commands on a schedule by creating a Prefect deployment. It's useful for tasks like fetching data or running scripts on a regular interval. Example for setting up a daily weather report for Chicago at 9 AM:
Copy code
bash
prefect shell serve "curl <http://wttr.in/Chicago?format=3>" --flow-name "Daily Chicago Weather Report" --cron-schedule "0 9 * * *" --deployment-name "Chicago Weather"
This schedules the fetching of Chicago's weather condition daily at 9 AM and tracks the execution results within the Prefect framework. ### Benefits 1. Immediate Feedback: Executes shell commands within Prefect framework for instant results. 2. Integration: Easily integrate external scripts or data fetching into your data workflows. 3. Visibility and Logging: Leverage Prefect's logging to track the execution and output of your shell tasks. 4. Automated Scheduling: Schedule shell commands to run at specified times. For more detailed documentation on Prefect CLI and its commands, you can refer to the following links: - Prefect 2.x CLI Documentation - Prefect 3.x CLI Documentation