Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bash Startup Script

Status
Not open for further replies.

bdw238

MIS
Dec 15, 2005
52
GB
I writing a Linux Startup Script to control starting, stopping, restarting a perl daemon script. I have copied the start and stop elements below:

AUTOFTPSCRIPT=/home/ftp/FTPTransfer.pl
case "$1" in
start)
echo -n "Starting FTP Transfer Script: "
$AUTOFTPSCRIPT
touch /var/lock/subsys/FTPTransfer
echo "OK"
;;
stop)
echo -n "Shutdown FTP Transfer Script:"
pResult=`ps aux |grep perl |egrep -v grep |awk '{print $2}'`
echo " "
echo "pResult = $pResult"
echo " "
if [ -n "$pResult" ]
then
kill -15 $pResult
rm -f /var/lock/subsys/FTPTransfer
else
echo "ERROR :- The FTP Transfer was not running previous"
fi
echo "OK"

etc....


The stop element works, however the start element starts the perl script and then kills the perl script on the start-up script exit!

Can anyone suggest anything?

Regards


Brian
 
Run it

nohup /home/ftp/FTPTransfer.pl &


Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Thanks for the reply Mike,

I got it working now, but I solved it by placing "exec" in front of /home/ftp/FTPTransfer.pl

Thanks

Brian
 
bdw238,

Using [tt]exec[/tt], the [tt]touch[/tt] of the lock file won't happen. You don't check for the lock in the fragment you posted, but I'm assuming you care about it somewhere else.

- Rod


IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

Wish you could view posts with a fixed font? Got Firefox & Greasemonkey? Give yourself the option.
 
Good point,

I'll modify the perl script to deal with the lock file.

Regards


Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top