Does anyone know why a system would not execute the script code within rc.local on bootup? I have a post configuration bash script that I want to run after the initial install of VMware ESX (Red Hat), and for some reason it doesn't seem to execute. I have the setup to log its start of execution and even its progress so that I can see how far it gets in case it fails at some point, but even when I look at that log, I am finding that didn't even started the execution of the script code. I already checked to see that script has execution permissions (755), what else should I be looking at?
Here is the first few lines of my code:
#!/bin/sh
echo >> /tmp/configLog ""
echo >> /tmp/configLog "Entering maintenance mode"
So, does /tmp/configLog exist? If so, your script is firing, and it's just dying somewhere.
Start with the basics:
It's not something simple like a typo is it? Should this:
Really be:
?
(Just like CK said in comment, now that I look)
Are you sure your system supports rc.local? If it isn't documented, you will need to follow all of the init scripts. You start at /etc/inittab. (You may find that from there you go to /etc/rc.d/rc)
On some systems, /etc/rc.d/rc.local is supported via a symlink /etc/rc.d/rcX.d/S99local. (where X is the appropriate runlevel).
If you're using RedHat, there's no real reason to not create your own init script, add it to /etc/rc.d/init.d, chkconfig --add the script, and chkconfig on the script. This will make the correct symlinks into the /etc/rc.d/rcX.d directories, and makes init scripts easy to deploy or disable.
Making use of the obsolete rc.local is fine for a quick hack if your system does support it, but it's not really appropriate for something important or permanent.
Not sure if processing of init scripts on linux is sequential or parallel, but Solaris systems launch the scripts sequentially. If an earlier init script hasn't yet finished (I see this sometimes due to sendmail/DNS dependency) the later ones don't get launched as quickly as you'd assume.
Use ps to see if an earlier init script is still running.
Perhaps there is a syntax error in the rc.local script. If you try to manually run it from the command line after the system has booted, does it execute correctly?
Have you checked the permissions on the directory which contains the rc.local file?
Shouldn't your code look more like this? 3 changes here:
rc.local was the BSD way of running startup scripts. Although many Linux versions do support having a file called "rc.local" which is run at startup, as I recall these required a bunch of symlinks and other glue to work, as Linux followed the Solaris way of handling startup scripts.
SELinux.
Try getenforce to see if selinux is switched on. It will return 1 or enforcing if it is turned on. Then if it is check dmesg to see if there is an selinux related error that looks like it might be to do with your script.
If that first line really does say #!/bin/hash then you will get an error similar to this:
when it runs.
You might also want to check that the script has execute permissions.