# (resolved) Execute code at startup automatically

**URL:** https://dietpi.com/forum/t/resolved-execute-code-at-startup-automatically/92
**Category:** General Discussion
**Created:** [30 September 2015 19:49 UTC](https://dietpi.com/forum/t/resolved-execute-code-at-startup-automatically/92 "2015-09-30T19:49:17Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![dimitrip](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/d/b4bc9f/32.png) [@dimitrip](https://dietpi.com/forum/u/dimitrip)
#### Post date: [30 September 2015 19:49 UTC](https://dietpi.com/forum/t/resolved-execute-code-at-startup-automatically/92/1 "2015-09-30T19:49:17Z")

</div>

Hi,

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

Thanks in advance.

---

<div class="post-metadata">

### Author: ![Fourdee](https://dietpi.com/forum/user_avatar/dietpi.com/fourdee/32/11_2.png) [@Fourdee](https://dietpi.com/forum/u/Fourdee)
#### Post date: [30 September 2015 20:11 UTC](https://dietpi.com/forum/t/resolved-execute-code-at-startup-automatically/92/2 "2015-09-30T20:11:58Z")

</div>

> [@dimitrip](#):
>
> 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:**

```plaintext
#!/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

```
