A story about trying to use cron on a Raspberry Pi and getting stuck in space

What I was trying to do

I tried to do the basic operation of trying to automatically execute a python script on a regular basis using cron on Raspberry Pi. Specifically, regular observation of temperature and humidity using the dht11 temperature and humidity sensor. I wrote the program to write to the csv file directly with Thonny.

Punch line

Check spaces when using cron. Especially before/usr/...

environment

devices: Raspberry Pi3B + sensor; dht11 OS: Rasbian NOOBS_ver_3_5_1 Language: Python 3

problem

I did the following in the terminal:

$ crontab -e

In your favorite editor, write the following at the bottom of the cron file (I use nano) I also asked which python3 and the terminal where the python3 being used is.

$ */1 * * * */usr/bin/python3 /home/pi/hoge/hoge1.py

It's not working, so check the status

$ sudo /etc/init.d/cron status

This is active. And restart cron

$ sudo /etc/init.d/cron restart

Still it doesn't work. Make various settings and see the log

tail -f /var/log/cron.log

Then it works every minute. However, there is no record (not written) in the csv file It's a mystery.

solution

It was a great beginner and a mistake.

$ */1 * * * * /usr/bin/python3 /home/pi/hoge/hoge1.py

What, it didn't seem to work properly when there wasn't one space before/usr. Also, in the place of *, */1 can be done without a space, but in the place of * * * *, one space is put in each. There are many articles on how to use cron, but there weren't many articles about space, so I'll leave it here for your reference.

Recommended Posts

A story about trying to use cron on a Raspberry Pi and getting stuck in space
[Django] A story about getting stuck in a swamp trying to validate a zip with form [TDD]
A story about trying to run JavaScripthon on Windows and giving up.
About the error I encountered when trying to use Adafruit_DHT from Python on a Raspberry Pi
A story about trying to implement a private variable in Python.
A story about trying to connect to MySQL using Heroku and giving up
A memorandum because I stumbled on trying to use MeCab in Python
A memorandum on how to use keras.preprocessing.image in Keras
Ubuntu 20.04 on raspberry pi 4 with OpenCV and use with python
A story that got stuck when trying to upgrade the Python version on GCE
Control music playback on a smartphone connected to Raspberry Pi 3 and bluetooth with AVRCP
A story about trying to introduce Linter in the middle of a Python (Flask) project
A story about getting the Atom field (XML telegram) of the Japan Meteorological Agency with Raspberry Pi and tweeting it
A story about how to specify a relative path in python.
[Note] A story about trying to override a class method with two underscores in Python 3 series.
Use NeoPixel on Raspberry Pi
A story about everything from data collection to AI development and Web application release in Python (3. AI development)
[Google Photo & Slack Photo Bot] A story about making a bot that acquires photos in Google Photos and sends them to Slack.
A story about trying to automate a chot when cooking for yourself
Use python on Raspberry Pi 3 to illuminate the LED (Hello World)
Think seriously about what language to use in programming education and programming education.
A story about wanting to think about garbled characters on GAE / P
Run Polyglot on Raspberry Pi to perform morphological analysis in English
A story about trying to improve the testing process of a system written in C language for 20 years
A story when a beginner gets stuck trying to build a vim 8.2 + python 3.8.2 + lua plugin environment on Ubuntu 18.04.4 LTS
A memo to simply use the illuminance sensor TSL2561 with Raspberry Pi 2
A story I was addicted to trying to install LightFM on Amazon Linux
Use python on Raspberry Pi 3 to light the LED with switch control!
[Memorandum] A story about trying OpenCV tutorial (face recognition) in a Windows environment
How to put a half-width space before letters and numbers in Python.
A story of a deep learning beginner trying to classify guitars on CNN
Connect to postgreSQL from Python and use stored procedures in a loop.
A story about a beginner trying hard to set up CentOS 8 (procedure memo)
[Raspberry Pi] Add a thermometer and a hygrometer
Set swap space on Ubuntu on Raspberry Pi
Use the Grove sensor on the Raspberry Pi
Wall to put OpenCV 3.1.0 in raspberry pi 3 and run sample on python3: ImportError: No module named cv2 solution
A story about Python pop and append
A story about a 503 error on Heroku open
How to install NumPy on Raspberry Pi
How to use is and == in Python
I have a question. Unable to make protocol buffers on raspberry pi 3 modelB.
Make a thermometer with Raspberry Pi and make it visible on the browser Part 3
Flutter in Docker-How to build and use a Flutter development environment inside a Docker container
Use libsixel to output Sixel in Python and output a Matplotlib graph to the terminal.
Use dHash to locate on the course from a scene in a racing game
[Hackathon] About making a tool that can be CD on Raspberry Pi [Convenient tool]
Build a PYNQ environment on Ultra96 V2 and log in to Jupyter Notebook
Use python on Raspberry Pi 3 and turn on the LED when it gets dark!
Use Raspberry Pi Python to TMP36 analog temperature sensor and MCP3008 AD converter
Build a Django environment on Raspberry Pi (MySQL)
Try using a QR code on a Raspberry Pi
How to use Raspberry Pi pie camera Python
A story about Go's global variables and scope
A story about displaying article-linked ads on Jubatus
Story of trying to use tensorboard with pytorch
A story about running Python on PHP on Heroku
A story about modifying Python and adding functions
Connect to MySQL with Python on Raspberry Pi
Build a Python development environment on Raspberry Pi
[Note] Use a wired LAN connection device with WiFi-Eth bridge on Raspberry Pi 4B