LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   setting the processes to run on startup (https://www.linuxquestions.org/questions/linux-newbie-8/setting-the-processes-to-run-on-startup-592180/)

laucian 10-16-2007 04:54 AM

setting the processes to run on startup
 
hi everybody,

i have this small script for a backup software..

and there is a hint to make links like this..

i am using suse 10.2 and i don't have the directories rc0.d or rc1.d in /etc/init.d. I only have them as files..

can someone help how to deal with it? how can i create links..

another question is, in general, how can i place a process on linux-startup so that i runs after each restart?

thnaks..

larkl 10-16-2007 06:20 AM

I don't use SUSE, but you might try their forum...

http://forums.suselinuxsupport.de/in...howtopic=52444

selva146 10-16-2007 06:54 AM

in redhat and fedora, you can put the script command in /etc/rc.local file

each and every restart this file gets executed

marozsas 10-16-2007 06:57 AM

The links you provided are both unreachable (403 Forbidden), but in general, scripts to be executed at boot time are in /etc/init.d/ and symbolic links in /etc/rc3.d (for runlevel 3) or /etc/rc5.d (for runlevel 5). The links have a name that starts with "Snn" where the number indicates de order of execution relative to others in the same folder. There are links starting with "Knn" to stops the service in a particular order too.
For example, my e-mail server is Postfix and it is started in runlevel 5.
Code:

[root@agente86 ~]# ls -l /etc/init.d/postfix /etc/rc5.d/S80postfix
-rwxr-xr-x 1 root root 2401 2007-06-14 07:29 /etc/init.d/postfix
lrwxrwxrwx 1 root root  17 2007-06-13 09:51 /etc/rc5.d/S80postfix -> ../init.d/postfix
[root@agente86 ~]#

So, if you have a complex script, let say mybackup, put it on /etc/init.d and create links on /etc/rc5.d (or /etc/rc3.d) with a name like "S91mybackup". This script must be executable (-rwx) and it expects an argument "start|stop|status". If this script follows the LSB, you can use the command "chkconfig myscript on/off" to automatically create/destroy the links in the appropriate order and run-level.

If it is a simple script that does not expect a start/stop argument, or just a command, edit the file /etc/init.d/boot.local and add the command at end of this file.

laucian 10-18-2007 05:07 AM

thanks for your reply..
i have done what you have said..here is a terminal log which shows the actual state.

Code:

mfc-falter:~ # cd /etc/init.d/
mfc-falter:/etc/init.d # ps aux | grep dsmc
root      4149  0.0  0.5  22640  4948 ?        Sl  12:01  0:00 /opt/tivoli/tsm/client/ba/bin/dsmc schedule
root      4244  0.0  0.0  4100  708 pts/0    S+  12:02  0:00 grep dsmc
mfc-falter:/etc/init.d # ./adsm stop
Stopping ADSM scheduler...
...stopped
mfc-falter:/etc/init.d # ps aux | grep dsmc
root      4252  0.0  0.0  4100  708 pts/0    S+  12:02  0:00 grep dsmc
mfc-falter:/etc/init.d # ./adsm start
Starting ADSM scheduler...
...started - done.
mfc-falter:/etc/init.d # ps aux | grep dsmc
root      4258  3.0  0.5  22636  4948 pts/0    Sl  12:02  0:00 /opt/tivoli/tsm/client/ba/bin/dsmc schedule
root      4261  0.0  0.0  4100  708 pts/0    S+  12:02  0:00 grep dsmc
mfc-falter:/etc/init.d # cd rc3.d/
mfc-falter:/etc/init.d/rc3.d # ls -l K21adsm
lrwxrwxrwx 1 root root 7 Oct 16 12:26 K21adsm -> ../adsm
mfc-falter:/etc/init.d/rc3.d # cd ..
mfc-falter:/etc/init.d # cd rc5.d/
mfc-falter:/etc/init.d/rc5.d # ls -l K21adsm
lrwxrwxrwx 1 root root 7 Oct 16 12:26 K21adsm -> ../adsm
mfc-falter:/etc/init.d/rc5.d #


but after restart, there is no dsmc process which should be run by the adsm script.
i can start and stop manually but not on startup.
any ideas? adsm is already wrx for root.

thanks..

marozsas 10-18-2007 05:31 AM

Quote:

Originally Posted by laucian (Post 2928242)
but after restart, there is no dsmc process which should be run by the adsm script.
i can start and stop manually but not on startup.
any ideas? adsm is already wrx for root.

By "restart" I presume you talking about a reboot of this computer, right ?
I think this is because there is no file "/etc/rc5.d/S80adsm" where "S" means "start". You show us only the "K21adsm" file which will kill the process in that run-level.

Test if your adsm script is LSB compliant by running "chkconfig --list". If you get a output that shows in what levels it is on and what levels it is off, then you don't need to create the links by your self. Use chkconfig interface to do that: "chkconfig adsm off" (to remove all links you eventually have created) followed by "chkconfig adsm on" and another "chkconfig --list" to see in what levels it will be run.

If it not follows the "chkconfig" interface, remove all K21adsm links and create the "Snnadsm" links in runlevel 3 and 5. You need to carefully choose the right "nn" in a way the script will run only after the services it depends on are already started.

janardhan narra 10-18-2007 05:53 AM

I Went To Customer To Install Linux In New System But It Is Not Installing At Last I Had Found That The Harddesk Is With Sata Cable.
Why Sata Hdd Not Support To Lunix
Then How To Install This
While Installing The System Does Not Find Any Hdd Please Help Me What To Do

marozsas 10-18-2007 06:02 AM

Quote:

Originally Posted by janardhan narra (Post 2928265)
I Went To Customer To Install Linux In New System But It Is Not Installing At Last I Had Found That The Harddesk Is With Sata Cable.
Why Sata Hdd Not Support To Lunix
Then How To Install This
While Installing The System Does Not Find Any Hdd Please Help Me What To Do

Start your own thread (New Thread button on top of forum's page) to get the maximum visibility and provide as much information you can at the first post. Tell us what computer is (mobo manufacture, disk model, etc) and what distro are you using to install.

laucian 10-18-2007 07:51 AM

thanks marozsas,
yes i was meaning a system boot (reset)
i have done everything as you said, i ran chkconfig --list, level 3 and 5 were on.
with chkconfig adsm on/off i set the level on and off.

now here is a directory overview
Code:

mfc-falter:/etc/init.d/rc3.d # ls -l *adsm*
lrwxrwxrwx 1 root root 7 Oct 18 14:43 K21adsm -> ../adsm
lrwxrwxrwx 1 root root 7 Oct 18 14:43 S01adsm -> ../adsm

mfc-falter:/etc/init.d/rc3.d # ls -l *adsm*
lrwxrwxrwx 1 root root 7 Oct 18 14:43 K21adsm -> ../adsm
lrwxrwxrwx 1 root root 7 Oct 18 14:43 S01adsm -> ../adsm

i am unfortunately not in the office..i have done this remote..
i will post the results when i can make the reboot but i think it should work out..

can you explain me the magic behind the curtain? what does LSB mean? what are all those levels? S is start, K is kill..what other things more?

marozsas 10-18-2007 09:21 AM

Quote:

Originally Posted by laucian (Post 2928395)
thanks marozsas,
can you explain me the magic behind the curtain? what does LSB mean? what are all those levels? S is start, K is kill..what other things more?

LSB means "Linux Standard Base" and it is a set of conventions to make easier the administration tasks on a linux box, whatever the distro is.

For instance, an init script that follows this conventions have a small header that is used by chkconfig and fellows, to deal with the links in /etc/rc.d and runlevels. Postfix has the following header and as you can see, the information bellow informs the proper order and pre-requisites to this script.
Code:

#
# /etc/init.d/postfix
#
### BEGIN INIT INFO
# Provides:      sendmail postfix
# Required-Start: $network $named $syslog $time
# Should-Start: cyrus ldap ypbind openslp
# Required-Stop:
# Default-Start:  3 5
# Default-Stop:
# Description:    start the Postfix MTA
### END INIT INFO

You can find more information on LSB's site.

And no, there is no other link type than the ones that start with "S" or "K".

Another convenience on SuSe are the rccommands - they are easy to type and to autocomplete by your shell:
In Suse, almost every init script can be start/stopped with the rccommands, i.e. rcpostfix start (or stop - there is also status and restart - in fact, is just a link from /sbin/rcpostfix to /etc/init.d/postfix - you can make the link yourself for adsm...)

In Redhat/Fedora, you can do the same with "service postfix start".
(I don't know if the above is under LSB conventions or not)

cheers,

laucian 10-23-2007 02:37 AM

i am sorry to say that but it did not work out..
it does not start after reboot..
i had to start it manually..

any further ideas?

marozsas 10-23-2007 05:19 AM

Please, give us the output of the following commands:
Code:

# runlevel
# cat /etc/issue
# chkconfig adsm
# chkconfig --list adsm
# ls -l /etc/init.d/adsm
# find /etc -type l -iname "*adsm"


laucian 10-23-2007 05:32 AM

before giving the outputs a quick question...

xinitrc file for the GUI responsible..
i mean the programs that i run via xinitrc file will be loaded only after i start KDE or GNOME..is this right?

laucian 10-23-2007 05:39 AM

Code:

mfc-falter:~ # runlevel
N 5

mfc-falter:~ # cat /etc/issue

Welcome to openSUSE 10.2 (X86-64) - Kernel \r (\l).


mfc-falter:~ # chkconfig adsm
adsm  on
mfc-falter:~ # chkconfig --list adsm
adsm                      0:off  1:off  2:off  3:on  4:off  5:on  6:off

mfc-falter:~ # ls -l /etc/init.d/adsm
-rwxr-xr-x 1 root root 1232 Oct 16 12:16 /etc/init.d/adsm
mfc-falter:~ # find /etc -type l -iname "*adsm"
/etc/init.d/rc5.d/K21adsm
/etc/init.d/rc5.d/S01adsm
/etc/init.d/rc3.d/K21adsm
/etc/init.d/rc3.d/S01adsm

and there is a modification that i have made..i think i should add that one here too..in this file,
Code:

mfc-falter:/etc/X11/xinit # ls -l xinitrc
-rwxr-xr-x 1 root root 1388 Oct 23 12:29 xinitrc

i just added..
Code:

#
# Add your own lines here...
#
/etc/init.d/adsm start


marozsas 10-23-2007 05:52 AM

Quote:

Originally Posted by laucian (Post 2933513)
before giving the outputs a quick question...

xinitrc file for the GUI responsible..
i mean the programs that i run via xinitrc file will be loaded only after i start KDE or GNOME..is this right?

no, not really. xinitrc run commands when the graphical mode starts, like the Graphical Display Manager, the login manager...


All times are GMT -5. The time now is 05:19 PM.