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

  • Home
  • SEARCH
  • 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 8791197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:48:36+00:00 2026-06-13T22:48:36+00:00

crontab fails to execute a Python script. The command line I am using to

  • 0

crontab fails to execute a Python script. The command line I am using to run the Python script is ok.

These are solutions I had tried:

  • add #!/usr/bin/env python at the top of the main.py
  • add PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin at the top of crontab
  • chmod 777 to the main.py file
  • service cron restart

my crontab is:

PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

*/1 * * * * python /home/python_prj/main.py

and the log in /var/log/syslog is:

Nov  6 07:08:01 localhost CRON[28146]: (root) CMD (python /home/python_prj/main.py)

and nothing else.

The main.py script calls some methods from other modules under python_prj, does that matter?

Anyone can help me?

  • 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-13T22:48:37+00:00Added an answer on June 13, 2026 at 10:48 pm

    The main.py script calls some methods from other modules under python_prj, does that matter?

    Yes, it does. All modules need to be findable at run time. You can accomplish this in several ways, but the most appropriate might be to set the PYTHONPATH variable in your crontab.

    You might also want to set the MAILTO variable in crontab so you get emails with any tracebacks.

    [update] here is the top of my crontab:

    www:~# crontab -l
    
    DJANGO_SETTINGS_MODULE=djangocron.settings
    PATH=...
    PYTHONPATH=/home/django
    MAILTO="cron-notices@example.com"
    ...
    # m h  dom mon dow   command
    10-50/10 * * * *               /home/django/cleanup_actions.py
    ...
    

    (running cleanup actions every 10 minutes, except at the top of the hour).

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

Sidebar

Related Questions

I am using crontab to run a python script that requires the module MySQLdb.
I'm using a crontab to run a maintenance script for my minecraft server. Most
I call a Python script from crontab. The script does generates colored output using
Trying to run scrapy crawl command using crontab under virtual environment, and getting below
I'm running a script from crontab that will just ssh and run a command
I've written a Rake script that should run automatically with Crontab. The script runs
If my crontab had the entry # m h dom mon dow command 12
I run a python shell from crontab every minute: * * * * *
In my crontab file I execute a script like so (I edit the crontab
I have created a Python script that I want to run daily via a

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.