Avatar of yarek
yarekFlag for France

asked on 

running programs at startup on linux redhat

I need to un a script
/script.sh
everytime Linux RedHat is loading (at startingup)
any idea ?
System ProgrammingLinux OS DevLinux

Avatar of undefined
Last Comment
nabeelmoidu
Avatar of nabeelmoidu
nabeelmoidu
Flag of United States of America image

add it to rc.local
Avatar of chrismanncalgavin
chrismanncalgavin

As above, seems the simplest way to do it.
Unless you want to specify the exact runlevel (what system level the script runs).
In this case runlevel 4 or 5 would be appropriate.

See the following article:
http://www.linux.com/articles/114107
Avatar of ofkr
ofkr
Flag of Singapore image

1) Create a file e.g "startup" in /etc/init.d/   [chmod that file "startup" must be an executable]

#!/bin/bash
/(path)/script.sh

2) run "update-rc.d startup defaults"

3) Reboot
Avatar of yarek
yarek
Flag of France image

ASKER

1) add it to rc.local
what rd.local ?
[root@ns38251 etc]# locate rc.local
/etc/rc.d/rc.local
/etc/rc.local

2)  Create a file e.g "startup" in /etc/init.d/   [chmod that file "startup" must be an executable]
#!/bin/bash
/(path)/script.sh
->OK DONE

2) run "update-rc.d startup defaults"
???? I tried :

[root@ns38251 etc]# update-rc.d startup defaults
bash: update-rc.d: command not found


I tried:
[root@ns38251 etc]# run "update-rc.d startup defaults"
bash: run: command not found

Apparently the ethod by ofkr of using "update-rc.d" applies to Debian based Linux distributions only. Not Redhat.
Avatar of nabeelmoidu
nabeelmoidu
Flag of United States of America image

its both the same.
the second one is a symbolic link to the first one.

update-rc.d is for debian.  In Red Hat its chkconfig. But that won't work here because for it to work, you need to write actual Sys-V init scripts.
Here you just need to add the line for calling your script in /etc/rc.local and make sure for your runlevel
rc.local is enabled, i.e.  make sure the symlinks to rc.local begin with S and not K. Eg
[root@updaweb employee]# ll /etc/rc*.d/*local
lrwxrwxrwx 1 root root  11 Mar  3 17:38 /etc/rc2.d/S99local -> ../rc.local

Avatar of yarek
yarek
Flag of France image

ASKER

cool down...

I AM a totally dummy in Linux.
I have a SSH console to my red5hat 7.2 distribution.
so once again, what should I edit so my script script.sh is launched if the server is rebooted ?
ASKER CERTIFIED SOLUTION
Avatar of nabeelmoidu
nabeelmoidu
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Linux
Linux

Linux is a UNIX-like open source operating system with hundreds of distinct distributions, including: Fedora, openSUSE, Ubuntu, Debian, Slackware, Gentoo, CentOS, and Arch Linux. Linux is generally associated with web and database servers, but has become popular in many niche industries and applications.

71K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo