As is typical with crontab issues. The environment is not the same as your user or even a sudo/root shell , and env python3 may not return anything (env simply searches through
Instead you should explicitly use the full path of python which can be found either as which python3 or which $(env python3) and use that full path in your crontab (typically /usr/...
We can ask cron to tell us what its environment is.
Create a shell script in your home directory (~/) as follows (or with the editor of your choice):
$ nano ~/envtst.sh
Enter/C+P the following in the editor:
echo "env report follows for user "$USER >> /home/pi/envtst.sh.out
env >> /home/pi/envtst.sh.out
echo "env report for ...
As I understand your question:
You have a cron job to reboot your RPi every night at 01:00; e.g.
0 1 * * * sudo reboot (#or something similar; e.g. shutdown -r now)
You have a 2nd cron job to restart your app using the @reboot facility in cron; e.g.
If you're certain that your 01:00 reboot is being executed successfully, ...
You've made a couple of mistakes, all par for the course. Let's step through this, get it working, and hopefully learn one other trick to help you help yourself in the future:
First, the "other trick": When you run a command from the terminal, your error messages stderr go to the terminal, and you see them immediately. When you run a command as a cron user,...
You can help yourself by collecting any error messages that are generated when cron runs your scripts. As you're aware, your shell will send error messages to the stderr stream when they occur. When you run the program from your terminal screen, this stderr stream goes to your terminal, and you see it. However, your cron job does NOT run under your userid, ...
You are using crontab to start programs on boot with option @reboot. In man 5 crontab you can read:
Please note that startup, as far as @reboot is concerned, is the time when the cron(8) daemon startup. In particular, it may be before some system daemons, or other facilities, were startup. This is due to the boot order sequence of the machine.
Here is a small bash script that you can call with cron, for example every 30 seconds.
for ((i=COUNT; i>0; i--)); do
/bin/ping -c1 -n 126.96.36.199 >/dev/null 2>&1
[ $? -eq 0 ] && exit 0
This will look $COUNT times if ping returns without error. If so the script ...
First, the command with the quotes can't work:
It might work without the quotes
It depends on the X Server. It is likely that you will also need to set XAUTHORITY.
You can test this from the command line:
env -i DISPLAY=:0.0 /usr/bin/python2.7 /home/pi/Desktop/...
No need to install xdotool or whatever. go to:
and comment out the line @point-rpi and remember, it will hide/center
the mouse pointer, not move it.
The path has changed as of Nov 2018 for the RPi. You can now find it here : /etc/xdg/lxsession/LXDE-pi/autostart
Nice puzzle... You should work toward discovering some more information to narrow this down:
You've stated, "All works fine when run directly from /home/pi". From that statement, it would seem that something is different when cron starts your job instead of you (your user id). And indeed it is. Among other things, the environment is different. Once you've ...
To mount the hard drive on boot up you can just add an entry into /etc/fstab, something like:
LABEL=hard-drive /media/hard-drive ext4 defaults 0 0
Instead of ext4 you may have to use the filesystem on your hard-drive.
To execute the clear command on startup just create a systemd Unit with:
rpi ~$ sudo systemctl --force --full edit clear-screen....
You can try to extend the bluetooth.service with the commands. Edit the service with:
rpi ~$ sudo systemctl edit bluetooth.service
In the empty editor insert these statements, save them and quit the editor:
ExecStartPre=/bin/bash -c 'echo 16 > /sys/kernel/debug/bluetooth/hci0/conn_min_interval; echo 17 > /sys/kernel/debug/bluetooth/hci0/...
Make sure cron is enabled.
systemctl status cron
If it is not enabled, enable it.
systemctl enable cron
Execute it from the global crontab.
Create a file /etc/cron.d/local or /etc/cron.d/ble. The name doesn't matter, just the directory /etc/cron.d. Add a line
@reboot root sh /home/pi/bleConn.sh
If you make /home/pi/bleConn.sh executable (and you ...
I've done this with Chromium browser, so might be similar, but the '--parameters' might be different.
I created a file named : autoChromium.desktop and placed it in:
The contents of the autoChromium.desktop file is :
Exec=/usr/bin/chromium-browser --noerrdialogs --disable-session-crashed-bubble --...
This is your crontab line in your image:
* * * * * cd / & cd home/pi/lufi/luftdaten-python & python3 custom_main.py &
You need to use a double ampersand (&&) in your crontab, not a single one like you've got (&).
The single ampersand sends a command into the background. Definitely not what you want here. The double ampersand means ...
@MarkSmith made a good suggestion. To help your troubleshooting, ask cron to redirect its error messages (stderr) to a file so that you can see it:
0 8 * * * echo "on 0" | /usr/bin/cec-client -s >> /home/pi/cronjoblog 2>&1
Assuming that you are logged in as user pi, this will put any error message generated in the file cronjoblog in your ...
In your first paragraph, you state some simple goals... some of which are not wanting it to be constantly looping, but also be responsive. You mention using cron to launch once per minute. If the code only checks the state of the GPIO pins, performs some work based on their state, then exits ... then the state of the GPIO pins could possibly be waiting up ...
I believe the problem lies with the way that the scripts are run within their own environment, copied when they are launched, so don't share changes made to that environment between them once they are launched.
To get your inter-process communication to work the way you want there are a few options you can try such as using files or pipes; message queues; ...
Try the following in crontab:
sudo python3 /home/pi/Example.py
You need the full path to Example.py
You don't really need the shebang.
Or sudo crontab -e for the root crontab with: