Operating System - HP-UX
1754805 Members
3520 Online
108825 Solutions
New Discussion юеВ

Re: Start a script with another script at boot

 
SOLVED
Go to solution
Carl Houseman
Super Advisor

Start a script with another script at boot

I've written a system monitoring script that I want to initiate at boot. This script needs to continue running indefinitely.

I've placed a start/stop script for it in /sbin/init.d and setup the link in rc3.d.

I can tell it tried to run when the system boots, but for some reason doesn't keep running.

If in a normal login and su'd to root I go to /sbin/init.d and type './mymonitor start' the monitoring script starts and keeps running just fine.

The line in the /sbin/init.d/mymonitor script that starts the monitoring script looks like this:

/usr/bin/nohup /somepath/monitor.sh >/somepath/monitor.log 2>&1 &

After booting the monitor.log file is created but contains 0 bytes. Similarly there is no indication of any trouble in /etc/rc.log.

Any ideas...? TIA.
3 REPLIES 3
Patrick Wallek
Honored Contributor
Solution

Re: Start a script with another script at boot

Is your mymonitor script perhaps dependent on some environment variable that may be set when you are logged in, but not set when the script runs at boot time?

Remember that the environment that gets used when starting the system is VERY limited. If there are any variables that are needed they should be set in the start script and dependent on anything external.
Carl Houseman
Super Advisor

Re: Start a script with another script at boot

I've thought about that, but if something wasn't working due to missing path, etc., there should be something recorded in rc.log or monitor_start.log. It's as thoough the process is just terminated as soon it starts.

I don't get to reboot the system very much to test this, but I will later today so I'll add something to the monitor.sh to write to the monitor_start.log file and try to see how far it gets.
Carl Houseman
Super Advisor

Re: Start a script with another script at boot

Well Patrick, you were correct, but I can't explain why my previous run at this didn't produce anything in the log file. This time the log file had a bunch of 'does not exist' errors for ping, grep, cut, sleep, etc. It would seem I needed to write *something* to the 1> file before it would pickup all the 2>&1 information. Strange.