Linux: Running a script at boot time

If you want to run a script at the initialization of your pc, for example to mount some disk, you should go to /etc/rc.d directory and edit the rc.local file:

[root@K8H6B1 /]# cd /etc/rc.d
[root@K8H6B1 rc.d]# vi rc.local

There you can put the script you want to run.

In this example: /home/nista/mount.sh, which mounts all the necessary disks:

#!/bin/sh
#
### BEGIN INIT INFO
# Provides: rc.local
# X-Mandriva-Compat-Mode
# Default-Start: 2 3 4 5
# Short-Description: Local initialization script
# Description: This script will be executed *after* all the other init scripts.
#              You can put your own initialization stuff in here if you don't
#              want to do the full Sys V style init stuff.
### END INIT INFO


touch /var/lock/subsys/local

/home/nista/mount.sh

Leave a Reply