(resolved) Execute code at startup automatically

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
Post Reply
dimitrip
Posts: 8
Joined: Wed Sep 23, 2015 12:40 pm

(resolved) Execute code at startup automatically

Post by dimitrip »

Hi,

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

Thanks in advance.
User avatar
Fourdee
Site Admin
Posts: 2782
Joined: Tue Feb 06, 2007 1:36 pm

Re: Execute code at startup automatically

Post 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
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
Post Reply