Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi, I want to create a script in the init.d directory and then create a link in rc3.d that links to init.d/myscript
Does any one know how to do that in RedHat Linux 7.1. What I though to do is to create another script for the link but wondering if there is another way to do this. BTW this will be used to start things at boot time and stuff.
ln (source) (target), so
ln -s /etc/rc.d/init.d/myScript /etc/rc.d/rc3.d/SmyScript
watch the _S_ in front of the link in rc3.d, stands for start, K for kill.
Theres no need to create a script for the link, if u want to execute the script conditionally just parse for the conditions from myScript.
Just create the script and place it in the init.d directory. In the rc3.d directory, to create a link to "myscript" in init.d, you would issue this command:
ln -s /etc/init.d/myscript /etc/rc3.d/S55myscript
(note that I put full pathnames to make it easier to keep track).
The -s option creates a symbolic link, which creates a file in your rc3.d directory that points to your script in init.d
say u only want to start a script which starts the software watchdog only if dhcpcd is running, then u could try getting the PID for SSHD. The script is always called with an argument and executes 1 test _before_ the passing argument is handled. This fictive script finds out if my kernel version is above 2.2.17 (a bit lame way but it works for me) before continuing and will try to see if the Process ID for dhcpcd is present (-n, not empty), else restart networking and start this script ($0) with the start arg again. if it is present it will start the daemon and finish off the rest of the script. (underscores replace spaces, indentation doesnt work here)
#!/bin/sh
KVER=$(cat /proc/version | gawk '{print $3}' | sed -e "s/[-,A-Z,.,2,1]//g")
if [ $KVER -le 7 ]; then
_______echo "Watchdog: bailing out."
_______exit 1
fi
case "$1" in
_______start)
______________if [ -n $(pidof dhcpcd) ]; then
_____________________/etc/rc.d/init.d/network restart
_____________________$0 start
______________else
_____________________daemon watchdog
_____________________echo "Watchdog: started."
______________fi
______________;;
etc.
everything u can think of can be tested before running stuff; time, diskspace, amount of incoming tcp/ip packages with the TOS bit set to 0x01 0x02...
*be cautious with scripts u didnt write ureself
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.