Question

"/bin/sh 1 /usr/bin/crontab not found" Cron job not working Django

I deployed my Django project on Digital Ocean app platform and every thing is working fantastic but there’s one problem I have one scheduled task on my website which I running through crontab (Django-crontab) but when I’m running the command python manage.py crontab to add my cronjobs in the app platform console I am getting this:

/bin/sh 1 /usr/bin/crontab not found

I have searched to solve it everywhere but I am not able to do so. Any help from your side will be appreciated.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

alexdo
Site Moderator
Site Moderator badge
February 29, 2024

Heya, @6474230cdcb2403bb352f0905c1560

I believe a similar question was asked before in our community which you can check here:

https://www.digitalocean.com/community/questions/how-to-regularly-run-django-management-commands-on-app-platform

At this time App Platform doesn’t have support to run scheduled tasks (aside from pre/post deployment jobs).

However, if you’re willing to run Django in a container image that your own, you can run cron in tandem with Django to execute whatever management commands that you’d like.

For example:

FROM python:buster

# Install cron (also anything else for Django)
RUN apt-get update \
    && apt-get install -y cron \
    && apt-get update -y

# Assuming you have some scripts that might execute some
# management commands
COPY *.sh /scripts/
RUN chmod +x /scripts/*.sh

WORKDIR /scripts

# Run at the beginning of the hour
RUN echo "0 * * * * root /scripts/management_command.sh" >/etc/cron.d/management_command

# Run both Django and cron together
CMD [ "sh", "-c", "cron && <cmd to run Django>" ]

Hope this helps!

KFSys
Site Moderator
Site Moderator badge
February 22, 2024

Heya @6474230cdcb2403bb352f0905c1560,

I don’t think you can use the crontab on App Platform that is part of the limitation of being on a managed platform.

You can suggest it as a feature though in the ideas board

https://ideas.digitalocean.com/

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel