5MP Cam Running Code on Start-up NOT WORKING

Hello, I’m trying to build like my own surveillance system. Right now I have one 5MP camera connected to my Rpi4. The main goal is to record video and then store it to an external USB.

When I open the command window I type the following:

raspivid -o /media/pi/USB_STICK/video.h264

When I run this, it works fine, the video records and stores in the external USB. I then needed to have this code run as soon as the pi gets power, so the camera starts recording as soon as the pi is powered.

I followed a youtube video where I was instructed to run:

sudo crontab -e

Then at the end of the text in the window, I type the code:

@reboot sh /home/pi/cam_start.sh &

The file ‘cam_start.sh’ contains the line of code I first wrote

When the pi turns on, the camera starts recording before it gives me the Rpi desktop (which is great) BUT then it stops and the file doesn’t save. I don’t get an error or anything, I only know it doesn’t save because I go to the USB, and there isn’t a video file.




Since the camera is working, it is beyond our knowledge to check why it doesn’t work for your specific use-case.