Can't figure out how to set up autostart?

Having issues with your DietPi installation, or, found a bug? Post it here.
Post Reply
Cam_2002
Posts: 2
Joined: Sat Jan 06, 2018 3:26 am

Can't figure out how to set up autostart?

Post by Cam_2002 »

I have installed dietpi successfully and I would like to run the command "sh /root/start.sh" automatically when the pi is turned on.

start.sh currently contains one line, "mkdir /root/testdir", just to test that it works.

I have tried typing "sudo dietpi-autostart", which opens the auto start window. I selected Custom: /etc/dietpi/autostart.sh. The screen cleared for a second, no text, then back to the DietPi-AutoStart menu. I exited. I then ran "sudo nano /etc/dietpi/autostart.sh", and in that file I have "sh /root/start.sh". I Ctrl-O, Ctrl-X'd and rebooted. I logged in, then tried "ls", and I don't have the testdir folder. Ideas?
Cam_2002
Posts: 2
Joined: Sat Jan 06, 2018 3:26 am

Re: Can't figure out how to set up autostart?

Post by Cam_2002 »

I found a dirty solution by adding the line "/bin/sh /root/autostart.sh &" to the file "/DietPi/dietpi/boot".
User avatar
johnvick
Legend
Posts: 693
Joined: Wed Jun 08, 2016 11:53 am
Location: New Zealand

Re: Can't figure out how to set up autostart?

Post by johnvick »

Not the best solution as the boot file could be updated and your startup script then wouldn't run.

Cron will do the job - there are many tutorials on this such as:

https://www.raspberrypi.org/documentati ... ge/cron.md

Skip the bit on gnome-schedule and concentrate on crontab -e.

John
User avatar
WarHawk
Posts: 610
Joined: Thu Jul 20, 2017 8:55 am

Re: Can't figure out how to set up autostart?

Post by WarHawk »

does any changes occur to /etc/rc.local?
Post Reply