Rasbian run automatically after boot-up

  • Thread starter Thread starter mizieahmad
  • Start date Start date
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..
 
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
2K
  • · Replies 22 ·
Replies
22
Views
2K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 0 ·
Replies
0
Views
3K
Replies
5
Views
2K
  • · Replies 33 ·
2
Replies
33
Views
3K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 12 ·
Replies
12
Views
12K
  • · Replies 3 ·
Replies
3
Views
2K