Search code examples
pythonpython-3.xshellcroncron-task

Cronjob on Ubuntu Mate for Raspberry stops right after execution


I use a RaspberryPi 3 with UbuntuMate 16.04. On it, I want to start a little Python (3.5) program every midnight. For that I call a little shell script, so that I can change into the wanted directory comfortably.

crontab:

5 0 * * * /path/to/script/start.sh

start.sh (yes, it's executable):

#!/bin/bash

cd /path/to/wanted/workingDir/
python3.5 ControllerQueue.py
#also tried: python3.5 ControllerQueue.py &

Now if I execute the programm or script from the terminal, everything runs fine. But if I use the crontab it starts the script and stops right after. I also tried running the programm directly but get the same outcome. The paths are correct as I copied the workingDir path from the crontab-file and started it via the terminal.

Is there something I overlook?


Solution

  • As stofvl suggested, I saved the error output of my shell script. It turns out that I needed to add a display. My programm is divided into two scripts. One which provides a GUI and the other main application. The script only starts the main application, without the GUI, but it seems that this didn't matter.

    This discussion helped me solve the problem.