Rasbian run automatically after boot-up

  • Thread starter Thread starter mizieahmad
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around automating the execution of a Python script on a Raspberry Pi 3 running Raspbian after boot-up, particularly in the context of a surveillance camera project. Participants explore various methods to achieve this automation, including the use of cron jobs and modifications to the rc.local file.

Discussion Character

  • Technical explanation
  • Exploratory

Main Points Raised

  • One participant seeks assistance in running a Python script automatically upon booting the Raspberry Pi.
  • Another participant suggests using the cron command in Linux to schedule tasks, providing a link for further reading.
  • A different participant mentions editing the rc.local file as an alternative method to run commands at boot, noting its usefulness for headless setups.
  • Concerns are raised about ensuring commands are run in the background to avoid stalling the boot process, with one participant emphasizing the importance of following directions carefully.
  • There is a discussion about the use of the ampersand ("&") to run commands in a separate process, with some participants expressing uncertainty about its effectiveness in preventing boot delays.
  • One participant acknowledges learning about the "@reboot" feature in cron for running tasks at startup, contrasting it with their previous experience using time functions.

Areas of Agreement / Disagreement

Participants generally agree on the methods discussed for automating script execution, but there are varying levels of familiarity and understanding regarding the implications of running commands in the background and the specific configurations required.

Contextual Notes

Some participants highlight the need for careful implementation of commands in the rc.local file to avoid boot issues, indicating potential limitations in understanding the nuances of background processes and scheduling tasks.

mizieahmad
Messages
15
Reaction score
1
hello my friends, i need our help to explain to my. i am in project camera surveillance using raspberry pi 3 and i using rasbian. so the problem is every time i startup, i need to open the phyton and run them. i want to know if possible to run the file automatically after boot like bare metal..
 
Technology news on Phys.org
Look at the cron command in Linux. It allows you to setup tasks to run at set times.

https://www.raspberrypi.org/documentation/linux/usage/cron.md
 
  • Like
Likes   Reactions: berkeman
cron is one way. The other way, that I was somewhat familiar with from Ubuntu is editing the rc.local file. Similar structure in Raspberian:

https://www.raspberrypi.org/documentation/linux/usage/rc-local.md

In order to have a command or program run when the Pi boots, you can add commands to the rc.local file. This is especially useful if you want to be able to plug your Pi into power headless, and have it run a program without configuration or a manual start.

An alternative for scheduled task management is cron.

see link for more.
 
Yes that looks like a good solution too with the caveat that you must do what the directions say ie:
- running the command in the background

or else the Pi won't complete the boot process.
 
jedishrfu said:
Yes that looks like a good solution too with the caveat that you must do what the directions say ie:
- running the command in the background

or else the Pi won't complete the boot process.

I thought the "&" option took care of that?

The ampersand allows the command to run in a separate process and continue booting with the process running.

Either way, I learned something - I wasn't aware of the "@reboot" approach to have cron run something at boot up, I had only ever used the time functions.
 
  • Like
Likes   Reactions: jedishrfu
Yes the ampersand runs it in the background. The article said don't forget to use it otherwise the PI will be stuck in the boot sequence waiting for the command to finish running.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 22 ·
Replies
22
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 0 ·
Replies
0
Views
2K
Replies
5
Views
2K
  • · Replies 33 ·
2
Replies
33
Views
3K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 12 ·
Replies
12
Views
11K
  • · Replies 3 ·
Replies
3
Views
2K