This is a small post on how to run some commands or scripts at the time of booting
Need for running commands/scripts at boot time
Some times we require to load some kernel modules or run a command to accomplish a task. If your command/script have to run continuously then use init start/stop scripts instead of keeping them in /etc/rc.local.
Running commands/scripts at boot time is achieved by using /etc/rc.local where rc stands for run-control.
Example 1: Load kernel modules through /etc/rc.local file
This is common in most of the Linux flavors. Edit /etc/rc.local file to enter modprob/insmod commands to execute them at the time of booting.
/sbin/modprob mac80211 /sbin/insmod /lib/modules/3.19.0-15-generic/kernel/drivers/net/wireless/iwlwifi/iwlwifi.ko
Save the file and exit.
Example 2: Run a command at the time of booting. If you don't want to run puppet agent and just want to run when the system boots use below example.
/usr/bin/puppet agent --no-daemonize --verbose --onetime
save the file and exit.
Example 3: Run a script at booting
Note: Always use complete path when keeping commands in /etc/rc.local so that it will not fail if PATH variable is not consulted.
Latest posts by Surendra Anne (see all)
- FREE: JOIN OUR DEVOPS TELEGRAM GROUPS - August 2, 2019
- Review: Whizlabs Practice Tests for AWS Certified Solutions Architect Professional (CSAP) - August 27, 2018
- How to use ohai/chef-shell to get node attributes - July 19, 2018
- wget download a file to a directory in Linux/Unix - June 4, 2018
- GIT: How to compare two GIT branches? - June 3, 2018