How can I log in and run a bash file at boot?

I got myself a minecraft server that turns on and off on specific hours but I don't want to type the commands every time it should start playing and let it run those commands after boot. I found an old askubuntu thread (for 12.04) where this is handled and let it run as root. But for security reasons, I don't want it to run as root. I would like to still be able to type in commands to like stop the server, so it cannot run my bash script somewhere hidden.


You could try to use a crontab entry for your user.

The command to run a command att boot is "@reboot".

Example of crontab entry:

@reboot   cd /home && sh ./myscript.sh