Question

I am using django_cron for a schedule a job, when i am use python manage.py runcrons this work good. but after adding the cron job in ubuntu cron list job is not executing. My setting.py is:

CRON_CLASSES = [
    "home.cron.HomeCronJob",
]

FAILED_RUNS_CRONJOB_EMAIL_PREFIX = []
INSTALLED_APPS = (
    'django.contrib.auth',
    '..................'
    'django_cron',
)

My cron.py file is:

from django_cron import CronJobBase, Schedule
from home.management.commands.auto_renueva import republishAds
class HomeCronJob(CronJobBase):
    RUN_EVERY_MINS = 2
    MIN_NUM_FAILURES = 2
    schedule = Schedule(run_every_mins=RUN_EVERY_MINS)
    code = 'home.home_cron_job'

    def do(self):
        republishAds()

then I have created a shell script for run this job, cron.sh:

#! /bin/bash
source /home/cis/ENV/muna/bin/activate
python /home/cis/DjangoLive/Newmunda/mund2anuncios/manage.py runcrons
deactivate

and the code i have added in ubuntu cron file are:

*/1 * * * *  /home/cis/DjangoLive/Newmunda/mund2anuncios/crons.sh >> /home/cis/Desktop/crons.log 3 >> /home/cis/Desktop/cron_errors.log

Please suggest me what i am doing wrong Here.

Thanks in Advance

No correct solution

OTHER TIPS

As a guess

python /home/cis/DjangoLive/Newmunda/mund2anuncios/manage.py runcrons

Will fail because PATH is not set in cron environment. You should include the full path to the python interpreter.

Other common error in cron jobs are no execution permissions on scripts. Normally cron errors are emailed to root, so you should have more info about errors on root mailbox

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top