Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django Crontab not working on a specific time #115

Open
Jay2109 opened this issue Jul 21, 2020 · 6 comments
Open

Django Crontab not working on a specific time #115

Jay2109 opened this issue Jul 21, 2020 · 6 comments

Comments

@Jay2109
Copy link

Jay2109 commented Jul 21, 2020

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'),
]

@davidvpe
Copy link

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
Copy link

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

@watsonhaw5566
Copy link

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.

@aakash-mishra
Copy link

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"]`

@Krymets
Copy link

Krymets commented Aug 31, 2023

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

@hnhegde
Copy link

hnhegde commented Nov 5, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants