uv icon indicating copy to clipboard operation
uv copied to clipboard

Improve documentation on how to run uv script in a cron

Open CedricRaison opened this issue 8 months ago • 3 comments

Summary

I wanted to use uv in a cron to run a task. It's really the "classic" usage.

I have my project in /root/my_project. There is inside a .venv folder containing all dependencies. There is a file /root/my_project/task.py in my project that import a few libraries (ex: requests) and do things.

I wanted to run the command uv run /root/my_project/task.py in a cronjob to run my task but it didn’t activate the virtual environment so I had a import error.

The solution I found to run my command in my cron was to use /root/my_project/.venv/bin/python3 /root/my_project/tasks.py.

It's really the everyday usage and I'm pretty sure it's possible to use with the command uv run.

So if it's the case that would be great to improve the documentation on this specific case.

CedricRaison avatar Mar 05 '25 22:03 CedricRaison