create and run bash script on start of runlevel5

General support questions
Post Reply
kapparino
Posts: 3
Joined: 2015/05/21 14:26:21

create and run bash script on start of runlevel5

Post by kapparino » 2015/05/21 14:28:30

I have created a following hello bash script:

Code: Select all

    #!/bin/sh
    
    echo "Hello Run Level 5"
I put this script in the /etc/rc.d/rc5.d directory with a name S100RunLevel5. How can I make this script to run terminal and show text, once I login to GUI?

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: create and run bash script on start of runlevel5

Post by gerald_clark » 2015/05/21 14:41:53

You can't.
Scripts in rc5.d run when the system enters runlevel 5, not when you login.
If you want something to run at login you need to use the startup facility of the window manager you are using.
For Gnome, it is System->Preferences->Startup Applications.

kapparino
Posts: 3
Joined: 2015/05/21 14:26:21

Re: create and run bash script on start of runlevel5

Post by kapparino » 2015/05/21 14:57:20

gerald_clark wrote:You can't.
Scripts in rc5.d run when the system enters runlevel 5, not when you login.
If you want something to run at login you need to use the startup facility of the window manager you are using.
For Gnome, it is System->Preferences->Startup Applications.
I have a task, to create my own runlevel script that runs arbitrary script or program at boot, how would i do that ?
So does it mean, that it's just enough to create a script and put in the folder rc#.d right ? But how can I present in console or somewhere, that it had been executed ?
Last edited by kapparino on 2015/05/21 19:29:26, edited 1 time in total.

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: create and run bash script on start of runlevel5

Post by gerald_clark » 2015/05/21 15:06:02

There are many examples in /etc/rcd./init.d.
There are also instructions in /usr/share/doc/initscripts*/sysvinitfiles.

You did not ask about running a program at boot.
You said you wanted it to run at login.
That is not the same thing.

We do not do student homework assignments here.
You are supposed to do that yourself.

The references above should get you started.

kapparino
Posts: 3
Joined: 2015/05/21 14:26:21

Re: create and run bash script on start of runlevel5

Post by kapparino » 2015/05/21 15:08:29

Thank you for a reference.

XiangJ
Posts: 23
Joined: 2013/03/20 06:41:29
Location: Shanghai, China

Re: create and run bash script on start of runlevel5

Post by XiangJ » 2015/05/22 02:26:10

Hi,
General boot process with runlevel 5 will stop at a login GUI and waiting for user to input account.
1. Modify /etc/gdm/custom.conf as below to skip the login GUI
[daemon]
AutomaticLogin=root
AutomaticLoginEnable=true

2. Add below line in the X Windows startup script /etc/X11/xinit/xinitrc.d/localuser.sh
gnome-terminal –x [sh your-script-path]

Post Reply