django-crontab
django-crontab copied to clipboard
Django Crontab not working on a specific time
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'), ]
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
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
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.
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"]`
It's a pity, but the project is dead. Can anyone recommend a cron for django?
@kraiz if you need help maintaining the project, I can help.