Run bash script on boot time on centos
How to Auto Execute Commands/Scripts During Reboot or Startup on centos . Many method to execute a command or run scripts during startup.
Edit crontab
To run a script called /home/huuphan/auto_excute.sh
And add your script at the bottom of the file /etc/rc.d/rc.local
Method 1: Linux Execute Cron Job After System Reboot
Use @reboot in cron scheduler. It will run once, at startup after reboot your system.Edit crontab
# crontab -e
To run a script called /home/huuphan/auto_excute.sh
@reboot /home/huuphan/auto_excute.sh
Method 2: Using /etc/rc.d/rc.local file
This method is vaild for systemd-based distributions. To grant execute permission to /etc/rc.d/rc.local# chmod +x /etc/rc.d/rc.local
And add your script at the bottom of the file /etc/rc.d/rc.local
# echo "/home/huuphan/auto_excute.sh" >> /etc/rc.d/rc.local
Comments
Post a Comment