django-crontab icon indicating copy to clipboard operation
django-crontab copied to clipboard

Django Crontab not working on a specific time

Open Jay2109 opened this issue 4 years ago • 6 comments

Environment & Versions

  • Operating system:
  • Python:
  • Django:
  • django-crontab:

Settings

I f I try to run this code i.e it must run at 8:10pm and 8:59 pm it doesnt work the cron job gets added but it doesnot executes CRONJOBS=[ ('10 20 * * *', 'stockssentiment.cron.ticker_yahoo'), ('59 20 * * *', 'sentimentor.cron.sentiment','>> /tmp/scheduled_job.log'), ]

But same code if I edit and make it to run every minute it works but that functionality is not my requirement If I do followig changes it works CRONJOBS=[ ('10 20 * * *', 'stockssentiment.cron.ticker_yahoo'), ('59 20 * * *', 'sentimentor.cron.sentiment','>> /tmp/scheduled_job.log'), ]

Jay2109 avatar Jul 21 '20 21:07 Jay2109

Hey @Jay2109 I think kraiiz abandoned the project, but I was having this same issue just now, and after quite a log of debugging I figured that it works, but the cron service is running in UTC time only which is a bit messy considering DST in some countries, so I still need to figure out how to change that to different timezones

davidvpe avatar Nov 13 '20 21:11 davidvpe

ok so, if you are using docker like me, you can do this on your Dockerfile

RUN rm /etc/localtime RUN ln -s /usr/share/zoneinfo/America/Lima /etc/localtime

In my case I set the timezone to America/Liima you can change that for whatever timezone you want The path for the timezones might differ depending on the distribution you use. and for that Google is your friend

davidvpe avatar Nov 13 '20 22:11 davidvpe

ok so, if you are using docker like me, you can do this on your Dockerfile

RUN rm /etc/localtime RUN ln -s /usr/share/zoneinfo/America/Lima /etc/localtime

In my case I set the timezone to America/Liima you can change that for whatever timezone you want The path for the timezones might differ depending on the distribution you use. and for that Google is your friend

I solve my timezone used RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime in my dockerfile. it's work.

watsonhaw5566 avatar Dec 09 '20 03:12 watsonhaw5566

ok so, if you are using docker like me, you can do this on your Dockerfile RUN rm /etc/localtime RUN ln -s /usr/share/zoneinfo/America/Lima /etc/localtime In my case I set the timezone to America/Liima you can change that for whatever timezone you want The path for the timezones might differ depending on the distribution you use. and for that Google is your friend

I solve my timezone used RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime in my dockerfile. it's work.

I am so surprised that this is still not working for me. Can you please take a look at below?

"crontab -l" shows my cron job correctly I have also created a symbolic link by using "RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime"

and this is my dockerfile:

`FROM python:3.9.2-alpine

set work directory

WORKDIR /usr/src/app

set environment variables

ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1

install dependencies

RUN pip install --upgrade pip COPY ./requirements.txt . RUN pip install -r requirements.txt

copy project

COPY . .

#Creating a soft symbolic link with force option (-sf) RUN ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime

EXPOSE 8800 RUN python manage.py crontab add CMD ["python", "manage.py", "runserver", "0.0.0.0:8800"]`

aakash-mishra avatar Apr 26 '21 18:04 aakash-mishra

It's a pity, but the project is dead. Can anyone recommend a cron for django?

Krymets avatar Aug 31 '23 11:08 Krymets

@kraiz if you need help maintaining the project, I can help.

hnhegde avatar Nov 05 '23 06:11 hnhegde