Rasbian run automatically after boot-up

  • Thread starter mizieahmad
  • Start date
In summary: 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.
  • #1
mizieahmad
16
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
  • #2
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 berkeman
  • #3
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.
 
  • #4
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.
 
  • #5
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 jedishrfu
  • #6
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.
 

1. How do I configure Rasbian to run automatically after boot-up?

To configure Rasbian to run automatically after boot-up, you can use the "systemctl" command to enable the desired service or program. You can also add the command or script to the "rc.local" file, which will run it on every boot.

2. Can I specify the order in which programs or services run after boot-up?

Yes, you can use the "systemctl" command to specify the order in which programs or services run after boot-up. You can also use the "rc.local" file to specify the order by adding the commands in the desired sequence.

3. How can I disable a program or service from running automatically after boot-up?

You can use the "systemctl" command to disable a program or service from running automatically after boot-up. You can also remove the command or script from the "rc.local" file to prevent it from running on every boot.

4. What should I do if a program or service fails to run automatically after boot-up?

If a program or service fails to run automatically after boot-up, you can check the logs to determine the cause of the failure. You can also try using the "systemctl" command to restart the service or troubleshoot any errors that may be preventing it from starting.

5. Is it possible to run multiple programs or services automatically after boot-up?

Yes, it is possible to run multiple programs or services automatically after boot-up. You can use the "systemctl" command to enable and specify the order of each program or service. Alternatively, you can add multiple commands or scripts to the "rc.local" file to run them in sequence.

Similar threads

  • Programming and Computer Science
Replies
22
Views
921
  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
0
Views
512
  • Programming and Computer Science
Replies
5
Views
984
  • Programming and Computer Science
Replies
4
Views
2K
  • Programming and Computer Science
Replies
14
Views
1K
  • Programming and Computer Science
Replies
33
Views
2K
  • Programming and Computer Science
Replies
12
Views
9K
  • Electrical Engineering
Replies
7
Views
1K
  • Programming and Computer Science
Replies
3
Views
1K
Back
Top