Auto Run a file on Boot on Dietpi

Hi!

On regular Raspberry Pi image (for headless / no monitor setup) , there is option to run a local file on boot using the entry on /etc/rc.local

on Dietpi, I dont find the file. How do I run a file on boot.

Do I use the dietpi-autostart to use a custom.sh?
Does this run the file in background or does this only work on console / desktop?

Thanks for your help!

Hi,

basically /etc/rc.local has been deprecated and is not used anymore to start service during boot process. Nowadays this is done by systemd. Even Raspberry Pi Foundation is not recommending the usage https://www.raspberrypi.org/documentation/linux/usage/rc-local.md

You have following options to get a script running during boot

  1. create your own service using systemd
  2. https://www.raspberrypi.org/documentation/linux/usage/systemd.md
  3. https://www.troublenow.org/752/debian-10-add-rc-local/
  4. using crontab to have a script exeuted during boot https://phoenixnap.com/kb/crontab-reboot
  5. dietpi-config AutoStart Option - Custom, will create as well a systemd service dietpi-autostart_custom and can be used to execute your command at boot

Thank you Joulinar !!

Hi, I am trying to run a script in Autostart option on Dietpi. For Raspberry Pi Buster the script used in /home/pi/config/lxsession/LXDE-pi/autostart
@lxterminal -e “/home/pi/Python_Code/bootup.sh”
However this will not work on Dietpi autostart config. What would be the correct command to run the file in /root/Python_code/bootup.sh.
Thanks for your help.

Some more clarification would be needed. What exactly you are trying to do? Do you like to execute thinks automatically while starting a desktop? Next to this, user pi is not exiting on DietPi. Hence, /home/pi/ did not exist as well.

A post was split to a new topic: How to autostart kodi and a custom script at boot