Running terminal commands at startup

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
Post Reply
rahulg
Posts: 1
Joined: Tue May 18, 2021 8:18 am

Running terminal commands at startup

Post by rahulg »

i want to run terminal coomand at startup which should play 3 mp3 files automatically at startup during boot in an infinit loop with omxplayer. plz anybody guide how can i achieve this. i was thinking of rc.local but its depreceated
User avatar
Joulinar
Posts: 4823
Joined: Sat Nov 16, 2019 12:49 am

Re: Running terminal commands at startup

Post by Joulinar »

Hi,

first you would need to the command to have you like to execute. If this is working already, you have basically 3 options.
  1. execute the command on boot using crontab
  2. create your own systemd service
  3. use DietPi auto start function (Custom script)
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
MichaIng
Site Admin
Posts: 3023
Joined: Sat Nov 18, 2017 6:21 pm

Re: Running terminal commands at startup

Post by MichaIng »

Generally you can also create scripts in /var/lib/dietpi/postboot.d/, but as long as the scripts run, the login prompt is delayed. So this seems not appropriate for your case as long as you cannot fork the playback loop into background within the script. The crontab @reboot function has a similar issue AFAIK, as those are executed one after another, so one running process blocks others from being executed.

For job that should run longer or forever in background, an own systemd service or dietpi-autostart custom script option are indeed the best fitting methods, as this is precisely what they are meant for.
Post Reply