Operating System - HP-UX
1834353 Members
2022 Online
110066 Solutions
New Discussion

Re: RC Scripts not starting

 
Aslam Ghumra_2
Frequent Advisor

RC Scripts not starting

Hi All

I have some scripts which I have created to start pfs_demon and pfsd, but they dont seem to work.

I have a similar script to start up other things and it seems fine at startup.

within the script,under start, I have the following :
/usr/sbin/pfs_mountd &
/usr/sbin/pfsd 4 &

I have also tried using nohup in fornt of it and also without the '&' at the end but to no avail.

Running it manually using S991pfs_mount start seems to work fine but not under the rc3.d scripts .

Any clues as to what I could be missing

Cheers, Aslam

13 REPLIES 13
Pete Randall
Outstanding Contributor

Re: RC Scripts not starting

Did you do the links from S991pfs_mount to your /sbin/init.d/pfs_mount script? Does your script ensure that all environment variables are set and full path names are used for all commands?


Pete

Pete
Aslam Ghumra_2
Frequent Advisor

Re: RC Scripts not starting

Hi

I have not linked it I have just put it into the script within /sbin/rc3.d/S991pfs_mount

All executables have full paths, but I dont have any environment variables to be set :

I have copied the script below

#!/sbin/sh
#
PATH=$PATH:/usr/sbin:/usr/bin:/sbin

# Daemons: psf_daemon

#

killproc() { # kill the named process(es)
for x in "$@";do
pid=`ps -e |grep "$x" |sed -e 's/^ *//' -e 's/ .*//'`
[ ! -z "$pid" ] && echo killing $x && kill $pid &
done
}

# return pid of the named process(es)
findproc() {
pid=`ps -e |grep "$1" |sed -e 's/^ *//' -e 's/ .*//'`
echo $pid
}

EXIT_OK=0
EXIT_ERR=1
EXIT_NA=2

case "$1" in
'start_msg')
echo "Starting pfs_mountd"
exit $EXIT_OK
;;
'stop_msg')
echo "Stopping pfs_mountd"
exit $EXIT_OK
;;
'start')
/usr/sbin/pfsd &
/usr/sbin/pfs_mountd &
exit $EXIT_OK
;;
'stop')
killproc pfs_mountd
exit $EXIT_OK
;;
*)
echo "Usage: /sbin/rc3.d/S991pfs_mountd { start | stop }"
exit $EXIT_ERR
;;
esac
Pete Randall
Outstanding Contributor

Re: RC Scripts not starting

/sbin/rc3.d/S991pfs_mount should be a link to /sbin/init.d/pfs_mount. The way startup works is that the entries in each of the rc?.d directories are parsed and the corresponding script in /sbin/init.d ends up being invoked with either the start paramater or the stop parameter. Placing the full script in /sbin/rc3.d is not going to work.


Pete

Pete
Aslam Ghumra_2
Frequent Advisor

Re: RC Scripts not starting

Hi

So I should copy this script to /sbin/init.d directpory and link to it.

I'll try and see.

Thanks again, Aslam
Aslam Ghumra_2
Frequent Advisor

Re: RC Scripts not starting

Hi again

copied the file to /sbin/init.d directory, and linked it.

Changing runlevel from 3 to 2 and back again to 3 seems to make it work.

However when rebooting this machine, the script still fails. I cannot seem to find the cause.

Aslam
Peter Godron
Honored Contributor

Re: RC Scripts not starting

Aslam,
add some debug steps into your code and then check the rc.log file after reboot.
Regards
Aslam Ghumra_2
Frequent Advisor

Re: RC Scripts not starting

In the script listed above, I have just added 'I am here' to try and see which part of the script it runs, and it actually goes to the correct case statements and runs the pfs_mountd command. But I have no idea why then the pfs_mountd fails, Does any one know how to debug this ?
RAC_1
Honored Contributor

Re: RC Scripts not starting

Why shutdown but not reboot.
----------------------------------------------------------

This document from HP explains more about shutdown vs reboot:
When bringing an HP-UX system down, Hewlett Packard recommends using
the shutdown(1M) command instead of the reboot command.

The shutdown(1M) command does additional preprocessing to prepare
the system for the reboot(1M) command. Primarily, shutdown(1M)
executes /sbin/rc to shutdown subsystems, unmount filesystems, and
other tasks to bring the system to run level 0. This process
ensures that the system is as quiet as possible before running the
reboot(1M) command.

The reboot(1M) command will then kill all remaining non-system
processes, sync the buffer cache, and then calls the reboot(2)
system call.

Note that issuing a reboot instead of a shutdown does not attempt
to stop any of the subsystems or unmount the file systems. While
reboot does attempt to kill non-system processes, other system
deamons may be active on the system. For example, the vxfsd
daemon may be attempting to flush the inode cache.

Any remaining activity on the system - when the reboot(2) system
call is made - can cause the system to hang during the reboot if
the activity locks any resource that the reboot(2) system call
needs to complete its processing, especially when reboot is trying
to flush the buffer cache.

Therefore, shutdown(1M) should be used instead of reboot(1M) to
provide a more comprehensive shutdown and limit the possibility of
system hangs during a reboot.
There is no substitute to HARDWORK
Aslam Ghumra_2
Frequent Advisor

Re: RC Scripts not starting

Hi

Sorry I ment I use "shutdown -r -y -o now" to reboot the server.

I think persnally its now the pfs_mountd and the pfsd commands, they have to be started up manually.

I've on a few systems here but none are running this automatically.

Cheers.
Aslam
Peter Godron
Honored Contributor

Re: RC Scripts not starting

Aslam,
Reading the man pages, just noticed:
"It is recommended that the pfs_mountd daemon be invoked by rc(1M).It must be invoked in the background."
Are running it in the background?
Regards
Aslam Ghumra_2
Frequent Advisor

Re: RC Scripts not starting

Hi, Yes I am trying to run pfs in the background.
Aslam Ghumra_2
Frequent Advisor

Re: RC Scripts not starting

I have now changed the script to

a) export PATH
b) add nohup before the script.

It now works, thanks to all.

Cheers
Aslam Ghumra_2
Frequent Advisor

Re: RC Scripts not starting

see posting above.