Skip to content

Run a script automatically on stratup

Ivstiv edited this page May 23, 2020 · 1 revision

In order to run a script on startup you would need to "deamonize" it. This can be done with variety of programs but the easiest option in my opinion would be to start a detached screen session from crontab.

Type crontab -e to edit your crontab and add the following line (edit everything inside <> to suit your case):

@reboot /usr/bin/screen -dmS <SCREEN_NAME> sh <SCRIPT-FILE>

For example if you want to start ip-mapper.sh automatically on reboot to run on the background:

@reboot /usr/bin/screen -dmS ip-mapper sh ip-mapper.sh

Clone this wiki locally