Raspberry Pi Zero Python Script Autorun on boot

Hello all,

I have developed a weather station using the following,

  1. External weather data using piicodev atmospheric sensor plus pi pico W and GPIO for Wind direction, Wind speed, and rain fall
  2. Internal weather display using pi zero coupled to second piicodev atmospheric sensor and 7" display plus Tkinter / python
    Communication between pi’s is WIFI and working well.

For the zero a virtual environment has been set up for the piicodev equipment.
Getting the zero is autorun the script on boot is my problem. At present I start from Thonny manually.

I have followed recommendations and created the following launcher.sh script, using nano.

*#!/bin/bash*
*source ~/bryan_object/bin/activate*
*python3 ~/bryan_object/Weather_displaydata.py*

I have then modified crontab as per, sudo crontab -e
with the following line

@reboot /home/pi/launcher.sh

Unfortunately I have had no success with autostart.

Apologies, as I am not sure how to copy code into the Topic script.

Would appreciate any support.

Bryan

1 Like

Hi Bryan. :slight_smile:

Good to see you back.
When you reboot your device, does it throw an error message in the syslogs?

#Search syslog for any line that looks like a crontab error.
grep CRON /var/log/syslog

Pixmusix hello,

I gave it a go from the home directory pi the response received is,

grep: /var/log/syslog: No such file or directory

Any ideas, I assume I can view this while the programme is running in the background?

Thank you.

Now that is a surprising error.
Its just saying the syslog is not where I expected it to be.

What os are you using?

This is what the test offered,

Distributor ID: Raspbian
Description: Raspbian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm

Thanks

I don’t have a Debian type distro at hand.

I read this thread where someone suggests they have removed system logs in raspberry pi os.
https://forums.raspberrypi.com/viewtopic.php?t=358028

Let me try something for you and I’ll get back in a few days.

Hopefully someone with more experience with crontab can weigh in and beat me to it.

I think syslog is the logging system.
/var/log/messages is a typical/default error log.

With cron job, I like to have full paths (or manage them) inside the script file as any path may or may not exist and may not be the same as your user space

the script file should also be able to just run outside of cron and work.