1 day ago · Tech · hide · 0 comments

If you are using uv to manage your python dependencies, you may run into difficulties when trying to execute a script from within a cron job, as the virtual environment has to be activated first. If you came for a quick answer, the solution is below. The key points are that you should use the full path to the uv binary, and that you should use the --project flag to ensure that the virtual environment is active when running the script. You can find the location of the uv installation by running which uv. Your crontab would look like this. To open the crontab for editing, run crontab -e, and it should open in your editor of choice. The below would run every minute (useful for testing). Change user to be the user on your computer, and filepaths as appropriate. * * * * * /home/user/.local/bin/uv run --project /home/user/code/test-cron /home/user/code/test-cron/main.py If you are looking for a guide on converting the crontab syntax into easier to understand time periods, you are welcome to…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.