Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'd like my openSuse 11.1 server to run a small shell script on startup. I've created a the script and put a symbolic link to the script in /etc/init.d/rc5.d/. Yet, the script does not get executed.

This is the script I am trying to run:

#!/bin/bash
#monitor RAID array
/sbin/mdadm --monitor --daemonize --mail=adrian@linuxplug.fli4l /dev/md0 /dev/md1 /dev/md2 /dev/md3
#start SVN server
/usr/bin/svnserve -d

The script works fine when I run it myself from the command line (svn server and mdadm are daemonized as expected). But it does not seem to be started when rebooting the server.

This might help you figure out what I am doing wrong:

linuxplug:~ # ls -l /etc/init.d/rc5.d/exe*
lrwxrwxrwx 1 root root 25 May 22 11:43 /etc/init.d/rc5.d/executeatstartup.sh -> /root/executeatstartup.sh
linuxplug:~ # ls -l /root/executeatstartup.sh
-rwxr-xr-x 1 root root 172 Apr 12 13:43 /root/executeatstartup.sh
linuxplug:~ # which svnserve
/usr/bin/svnserve

What am I doing wrong?

Edit: I've renamed the link to the shell script as follows:

linuxplug:~ # ls -l /etc/init.d/rc5.d/    
lrwxrwxrwx 1 root root 25 May 22 12:03 S99executeatstartup -> /root/executeatsta
    rtup.sh

However, the script still isn't run on startup.

share|improve this question
add comment

7 Answers 7

up vote 1 down vote accepted
+100

Have you tried adding a call to the script in your /etc/init.d/boot.local? Try it and see if that works better. There are several other boot.* files that are run at different parts of the startup.

share|improve this answer
add comment

you should have your link named S99something, where S stands for starting, and 99 stands for the order in which the scripts in that directory are started. see the other link in that directory...

Besides: you may want to rework the script to honour start / stop arguments, and add a K99something symlink to make sure the services are properly stop when leaving this run level.

share|improve this answer
    
Thanks for the hint! I've renamed the link to S99executeatstartup, but it still isn't run (see edit of my posting above). Anything else I missed? –  Adrian Grigore May 22 '09 at 10:20
1  
Maybe your default runlevel is 3 (non-graphical)? –  Node May 22 '09 at 10:28
    
nope, it's coming up to runlevel 5 –  Adrian Grigore May 22 '09 at 10:31
add comment

Have you allready followed the steps listed on the opensuse web site? That should definitely work.

There is a pretty good explanation at Cool Solutions as well

share|improve this answer
add comment

You should put that commands in /etc/rc.local (or equivalent in opensuse)

initscripts must have a certain syntax. You can check one of them for an example, but what you need is /etc/rc.local

share|improve this answer
    
There is no rc.local in opensuse. I've followed the tutorial at linux.derkeiler.com/Mailing-Lists/SuSE/2005-07/1773.html, but it still does not work. –  Adrian Grigore May 22 '09 at 12:13
add comment

There should definitely be a way to do what you want from the /etc/rc*. Another alternative you might want to look into is cron. With vixie-cron it's possible to specify tasks to run on reboot with the @reboot keyword in your crontab:

Instead of the first five fields, one of eight special strings may
appear:

string         meaning
------         -------
@reboot        Run once, at startup.
@yearly        Run once a year, "0 0 1 1 *".
@annually      (same as @yearly)
@monthly       Run once a month, "0 0 1 * *".
@weekly        Run once a week, "0 0 * * 0".
@daily         Run once a day, "0 0 * * *".
@midnight      (same as @daily)
@hourly        Run once an hour, "0 * * * *".

The above table is from a blog post by Jeremy Zawodny which I'm not allowed to post a link to as a new user. Search for "vixie-cron specify tasks on boot" on Google, and it's the first result.

As mentioned in the article, it's a great way to allows users to run commands at startup without granting them root access.

share|improve this answer
add comment

It's also worth checking /etc/inittab to ensire that you're booting into runlevel five by default, look for a line like:

id:2:initdefault:

That's from my debian laptop and shows that I boot into runlevel two by default (which is debian's default).

On RedHat derivatives (like openSuSE) runlevel five is the default when running X11, runlevel three is the default to boot to the console.

share|improve this answer
add comment

Does opensuse have selinux? If so is it turned on and is the context of your script the same as the other start up scripts? Try getenforce to see if selinux in installed an turned on. Try ls -lZ /etc/init.d/rc5.d/ to see the scripts' contexts

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.