How to run scripts after boot in Linux

10th August, 2019

Often there is need to run script after a reboot of the machine. Especially in case of AWS and you want to reduce the costs of the EC2 instances, it is advisable to start instances only when needed and then shut them down when no task is running in that machine. To achieve that it is very convenient if the scripts get exceuted by default after reboot.

First you need to launch EC2 instance and set everything up including all dependencies and a script to execute them all. 

$crontab -e

and then add

@reboot /bin/bash / 

Make sure about the executable and ownership rights of the file.


That's it !