Start ups

We may get into some situations when we need to execute certain scripts when our system boots up. This can be done in two methods

(1)After the system boots up, when the user gets logs into the gnome we can start up things by using “gnome-session-properties”,

Launch gnome-session-properties (type the same in run or in terminal)

Goto “Startup Programs” tab, you will see the list of start up programs that are already in list.

Click on “Add”, then type/browse the command to add followed by the arguments and options say “/usr/bin/xmessage Welcome”. Click on close.

Now logout and login to see our “Welcome” message. Note that this method is specific to the user and to the desktop environment we are using.

Do you know where this configuration is saved. Its important to know this, coz when you included some program or in-correct scripts that restarts the X, then your X will try to start whenever you loggin as a result we will never land on our desktop.

a new file “xmessage.desktop” under “~/.config/autostart/”. Try removing this file and check the gnome-session-properties.

If we need to run some scripts/command as the system boots, something like starting of apache server that gets started when the system boots or something that configures our network as the system boots up. Imagine i need a script that appends the boot time to a log file whenever the system boots up.

#File : /etc/init.d/

date >> /home/sathyz/tmp/date.log

create a symbolic link for this file and place it under the directory /etc/rc5.d/ (5 specifies the run level ). The link should be named with the prefix ‘S’ follwed by the priority number for e.g S39logdate. Remember that the scripts with prefix ‘S’ will be executed when we enter the run level and the scripts with prefix ‘K’ will be executed when we leave that run level.

    #cd /etc/rc5.d

    #ln -s  ../init.d/ S39logdate

    #ls -l


    lrwxrwxrwx 1 root root  19 2007-06-21 13:05 S25bluetooth -> ../init.d/bluetooth
    lrwxrwxrwx 1 root root  20 2007-07-22 21:39 S39logdate -> ../init.d/
    lrwxrwxrwx 1 root root  17 2007-06-21 13:04 S89anacron -> ../init.d/anacron
    lrwxrwxrwx 1 root root  13 2007-06-14 15:51 S89atd -> ../init.d/atd

now lets reboot and test the script,

If we want to remove the unwanted services activating when the system boots just find the respective file corresponding to the run level and break the link.

To do this simply, /etc/init.d/rc.local will be executed at the end of each multiuser level so we can append our commands to be executed in this script.

Note that in case of red hat based system ‘chkconfig’ allows us to add services to the start up.

technorati tags:,


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s