Page 1 of 1

(resolved) Execute code at startup automatically

Posted: Wed Sep 30, 2015 9:49 pm
by dimitrip
Hi,

How can I have some code we created to be executed automatically after startup (not as service).

Thanks in advance.

Re: Execute code at startup automatically

Posted: Wed Sep 30, 2015 10:11 pm
by Fourdee
dimitrip wrote:Hi,

How can I have some code we created to be executed automatically after startup (not as service).

Thanks in advance.
Your best bet would be to add your command to the /etc/rc.local file. This file is processed last after boot.

Example /etc/rc.local file:

Code: Select all

#!/bin/sh -e

/DietPi/dietpi/dietpi-services start

#My message
echo -e "This will be displayed during boot"

#create a file
echo -e "My test file" > /root/testfile

exit 0