I am trying to use my raspi to host a discord bot that every morning publishes the food in my school. I have setup a bronjob with crontab -e but it's not working.

Crontab lookis like this:

45 07 * 2-5 python3 /home/pi/Desktop/Python/dcfoodbot/new/send.py

30 10 * 1 python3 /home/pi/Desktop/Python/dcfoodbot/new/send.py

with blank line at the end. (Published later on mondays because food is updated that day and can sometimes be late). When i tried making it post every minuite for debuging it worked but setting it to a specific time, for example 26 18 * 2-5 python3.... did not work. I would really appreciate help!




45 07 * 2-5 python3 /home/pi/Desktop/Python/dcfoodbot/new/send.py

30 10 * 1 python3 /home/pi/Desktop/Python/dcfoodbot/new/send.py


45 07 * * 2-5 python3 /home/pi/Desktop/Python/dcfoodbot/new/send.py

30 10 * * 1 python3 /home/pi/Desktop/Python/dcfoodbot/new/send.py

  • Your crontab rule only has 4 time specifications. I think you want something like this 45 07 * * 1-5. this equates to At 07:45 on every day-of-week from Monday through Friday. See this site for details crontab.guru/#45_07___1-5 Commented Mar 23, 2022 at 18:10
  • 1
    You may also try /full/path/to/python3.
    – user68186
    Commented Mar 23, 2022 at 19:52
  • @SteveRobillard didn't work :( Tried it and still same result. Commented Mar 23, 2022 at 20:14
  • Try replacing cron with systemd-cron. It works the same way but integrates crontab entries into sudo systemctl
    – Dougie
    Commented Mar 23, 2022 at 20:49
  • You have 2 answers now; have you any feedback or questions?
    – Seamus
    Commented Mar 28, 2022 at 17:14

2 Answers 2


Your schedules: 45 07 * 2-5 & 30 10 * 1 are incomplete/erroneous. You could use some help from my friend "The crontab guru"; it gives you an English-language definition of a schedule that you input, and allows you to verify your schedule expression. Note that there are 5 fields, but you seem to have supplied only 4.

AFAIK, cron does verify schedule expressions for validity, and consequently it "fails silently" rather than throwing an error. Perhaps this verification is a difficult thing to do?

Nevertheless, it's always good practice to throw errors. Since cron is not attached to a user terminal, you typically won't see errors thrown by your cron jobs at the console. However, you may use a redirect in your crontab entry to capture those error (stderr) messages generated by your script. For example:

# FROM: 
python3 /home/pi/Desktop/Python/dcfoodbot/new/send.py

python3 /home/pi/Desktop/Python/dcfoodbot/new/send.py 2>> /home/pi/Desktop/myfailures.txt

Try defining the path of your Python environment first, and after that add the path to your Python script. This is (like) one of my settings:

30 23 * * * /home/pi/myprojectfolder/venv/bin/python /home/pi/myprojectfolder/scraper.py

Since my project runs in a virtual environment (the folder called venv, where I have lots of different packages installed), I let the system know I want to use that Python interpreter. After that, I tell the system what script to run.

If you don't have a virtual environment, try using your system's default Python path. Find out what that is by typing which python in your shell. You will get something like usr/bin/python and that will be your path.

So, in crontab you will have a single line with 3 commands, all separated by white space:

  1. when to run? (run every day at 23.30)
  2. where is Python?
  3. where is the script I want to run?

To see how to properly generate cron commands, see the website crontab.guru.

I hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.