Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9307001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T00:17:50+00:00 2026-06-19T00:17:50+00:00

How to run in crontab */1 * * * * /home/user/Desktop/job/dp/ python manage.py statistics

  • 0

How to run in crontab

*/1 * * * * /home/user/Desktop/job/dp/ python manage.py statistics

with virtual env? I need to activate virtualenv first(Otherwise it does not work)

This is my virtual env:

source job/bin/activate
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T00:17:51+00:00Added an answer on June 19, 2026 at 12:17 am

    EDITED:

    Try something like this:

    */1 * * * * . /path-to-env/bin/activate && /home/user/Desktop/job/dp/manage.py statistics
    

    This should be read as: activate the env and if that was successful, excute the manage.py script. Since manage.py is supposed to have a python shebang and the virtual env sets the correct python interpreter, this should work.

    Apparently cron usually runs with /bin/sh which does not know the source command. So one option is to use a dot as a source replacement. Another to set /bin/bash in the cron file:

    SHELL=/bin/bash
    */1 * * * * source /path-to-env/bin/activate && /home/user/Desktop/job/dp/manage.py statistics
    

    Read more about this issue at:
    http://codeinthehole.com/writing/running-django-cronjobs-within-a-virtualenv/
    The article doesn’t mention that source can be replaced by a ., but i’ve just tried it and it worked for me. So you have several options to choose from now, the article even has others. 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to run a lot of Django management commands in the crontab and
I run a python shell from crontab every minute: * * * * *
I am using crontab to run a python script that requires the module MySQLdb.
I'm trying to run a scheduled cron job using a crontab from a linux
I need to parse a crontab-like schedule definition in Python (e.g. 00 3 *
what happens to my script in python that does not run through crontab every
I want to set up a crontab to run a Python script. Say the
To start Diaspora sever need to run these command: cd /home/diaspora ./script/sever My server(Ubuntu
I'm trying to get a simple crontab job to run every 15 minutes and
I would like to set a job to run daily in the root crontab.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.