I have a script running at boot time, however it's giving me errors I see in the log file. When I run it manually, it runs fine - probably the environment is changed.Is there a way to run such a script in conditions it's running at boot without restarting?Script is located in /etc/init.d with a symlink in /etc/rc5.d/S97mounter.sh.
How to run a script as if it's running at boot?
environment variables;startup
You could run as rootenv - scriptnameThis will clear your environment before running the script, however, it will also keep your shell. To clear the environment and set the shell to sh, do the following:env -i /bin/sh -c scriptnameThis will then run the script using /bin/sh. However, this will not completely simulate the boot environment as this does not count for the other services that may not be running at the time.I have found a similar question for simulating the crontab environment and there is a very useful solution posted by mmccoo.Using this you could run this in a script and reboot the host, then use the environment file to load your environment:part of a boot script: env > /var/tmp/bootenvThen at normal runtime to set the same boot environment, do this:env - `cat /var/tmp/bootenv` /bin/sh -c scriptname