Linux – How to run a bash script automatically

bashkali-linux

I have a script named run.sh:

#!/bin/bash
cd /root/yowsup-master/src/
./yowsup-cli --interactive no --wait --autoack --config config.example

This script executes another script.

I tried adding my script path in /etc/rc.local but it doesn’t seem to work.

I also added it to startup application in Kali Linux it also doesn’t work.

I want my run.sh to execute automatically in the background when the computer starts.

Best Answer

Easy. Use a crontab entry like this:

@reboot  /replace/with/the/path/to/run.sh

To use that on your system, the best way is to never edit /etc/rc.local manually, but by just running crontab -e to edit your crontab entries. More details on this site.

Related Question