Hot answers tagged

6

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/...


5

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: #!/bin/sh echo "env report follows for user "$USER >> /home/pi/envtst.sh.out env >> /home/pi/envtst.sh.out echo "env report for ...


5

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. @reboot /path/to/your/flask/app If you're certain that your 01:00 reboot is being executed successfully, ...


4

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,...


3

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, ...


2

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. On ...


2

Here is a small bash script that you can call with cron, for example every 30 seconds. #!/bin/bash COUNT=3 INTERVAL=1 for ((i=COUNT; i>0; i--)); do /bin/ping -c1 -n 8.8.8.8 >/dev/null 2>&1 [ $? -eq 0 ] && exit 0 sleep $INTERVAL done /sbin/reboot This will look $COUNT times if ping returns without error. If so the script ...


2

First, the command with the quotes can't work: "/usr/bin/python2.7 /home/pi/Desktop/script.py" It might work without the quotes /usr/bin/python2.7 /home/pi/Desktop/script.py 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/...


2

No need to install xdotool or whatever. go to: /home/pi/.config/lxsession/LXDE-pi/autostart 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


1

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 ...


1

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....


1

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: [Service] ExecStartPre=/bin/bash -c 'echo 16 > /sys/kernel/debug/bluetooth/hci0/conn_min_interval; echo 17 > /sys/kernel/debug/bluetooth/hci0/...


1

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 ...


1

Welcome, Pete. Have you tried using a root crontab? sudo crontab -e


1

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: ~/.config/autostart The contents of the autoChromium.desktop file is : [Desktop Entry] Type=Application Exec=/usr/bin/chromium-browser --noerrdialogs --disable-session-crashed-bubble --...


1

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 ...


1

I found the solution... add sudo inside de os.popen() command: ipaddress = os.popen("sudo ifconfig wlan0 | grep 'inet' | awk '/inet / {print $2}'").read()


1

@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 ...


1

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 ...


1

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; ...


1

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: python3 /home/pi/Example.py


Only top voted, non community-wiki answers of a minimum length are eligible