Unable to run a Cron Job at Reboot with the following commands
Opened this issue · 3 comments
Initially, the aim of the project to be showcased in TechLab is that every morning, 0825, the Raspberry Pi will perform a startup, but it appears that there is no much information on how to make a raspberry pi to sleep and wake up at a certain time. So, we decided that the goal for now is to perform a reboot everyday at 0825, run the 3 commands to operate Object Recognition starting from 0830 to 1930, and having a screensaver at 1930. Although there are better ways to be implemented to provide a better power management system, this method is currently the most feasible way for us to do, or so we thought.
However, while running these 3 commands, there seems to be a problem.
$ cd tflite1/
$ source tflite1-env/bin/activate
$ python3 TFLite_detection_webcam.py --modeldir=Sample_TFLite_model
The issue is that even though the Cronjob was scheduled, nothing appeared. The 3 commands was then tested with a shell script with the link shown below, but still having no results.
https://github.com/bennedictbyy/ObjectRecognitionRaspberryPi/blob/master/test.sh
We are unsure whether if it is due to the virtual environment from the second command.
This project is based of the YouTube link as shown below:
https://www.youtube.com/watch?v=aimSGOAUI8Y
You haven't actually properly scripted your bash file.
Also, since your objective is to activate this file at startup, a better approach is to use a systemd script.
It looks like TFLite_detection_webcam.py
is your program you want to launch. Reference the answer here and see if you can rebuild your scripts around it.
Hi Ju Ping, I had tried out the 3 commands using systemd script. However, I am not sure why it isn't working when rebooted. The files that I created are startup.service and startup.sh which I had uploaded to the repository. May I ask is this the correct method of using systemd script? I followed the tutorial based on this video: https://www.youtube.com/watch?v=-aKb-k8B8xo
However I am also not familiar with what else that is needed to be included in the service file.
Do let me know if there is any mistakes that I had done, Thanks!
I will put this out of the way so it is clear immediately. I will not watch YouTube videos to see what you did. Either point towards published notes or write down the exact steps you made.