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

Become a contributor for community

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

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.