LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-20-2003, 06:50 PM   #1
MaverickApollo
Member
 
Registered: Oct 2003
Distribution: Debian
Posts: 57

Rep: Reputation: 15
Start Up Scripts not running


I have a script that runs fine when I have typed its' name on the command line such as

/etc/rc.d/init.d/scriptname start

This starts it fine without problems. Doing tail /var/log/messages does not show any errors.
I have set it to start at boot up, but it dosnt run. I need to enter the script name manually before it runs.

If I do a chkconfig --list it shows it is registered in run levels 2345, which is where it should be. It is scheduled to start on system boot by doing

/usr/sbin/setup and going to system setup, and setting it there. I have also checked in the RH9 GUI version of the system startup util.

The full paths are in the file.

Anyone got any ideas?

Here is a copy

#!/bin/bash
#
# Script to run Fetchmail software at boot time.
#
# Last Updated: 31st August 2003
#
# This script is based upon the init scripts
# as used on Red Hat Linux.
#
# The script has been tested on RH 7.x, 8.0, and 9.0
#
# Author: Gary Myers AMBCS
# mailto: gary @ gaztronics.co.uk
#
# This script is realeased under the terms of the GPL.
# You can source a copy at:
#

#====================================================================
# Run level information
#
# chkconfig: 2345 99 90
# description: Fetchmail
#
# Run "/sbin/chkconfig --add seti" to add the Run levels;
# this *should* setup the symlinks!
#====================================================================

PATH=/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/bin
#====================================================================
# Set the path to the executable.
#
FETCHMAIL=/usr/bin/fetchmail

# Set the path to the runtime control file.
#
FRC=/root/.fetchmailrc

# Path to the lock file.
#
LOCK_FILE=/var/lock/subsys/fetchmail

# Set this time for daemon operations.
# Default for this config is 1 hour.
#
TIME=200

#====================================================================

#====================================================================

# System checks:

# Source function library
. /etc/rc.d/init.d/functions

# Check that networking is up.
# No point in trying to send or recieve otherwise!!
[ ${NETWORKING} ="yes" ] || exit 0

# Check we have the fetchmail program installed.
if [ ! -x $FETCHMAIL ] ; then
echo "Cannot find Fetchmail executable!"
exit 0
fi

# Check the .fetchmailrc file exists - fetchmail doesn't run
# in daemon mode without it.

if [ ! -f $FRC ] ; then
echo "Cannot find the runtime control file!"
exit 0
fi

#====================================================================

prog=$"Fetchmail"

RETVAL=0

start() {
if [ -f $LOCK_FILE ]; then
echo "Fetchmail is already running!"
exit 0

else

echo -n $"Starting $prog: "
$FETCHMAIL --daemon $TIME >/dev/null 2>&1
fi

RETVAL=$?
[ $RETVAL -eq 0 ] && success
echo
[ $RETVAL -eq 0 ] && touch $LOCK_FILE
return $RETVAL
}

stop() {
echo -n $"Shutting down $prog: "
killproc fetchmail
RETVAL=$?
[ $RETVAL -eq 0 ]
rm -f $LOCK_FILE
echo
return $RETVAL
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
condrestart)
if [ -f $LOCK_FILE ]; then
stop
start
RETVAL=$?
fi
;;
status)
status fetchmail
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
RETVAL=1
esac

exit $RETVAL
 
Old 10-20-2003, 08:00 PM   #2
clacour
Member
 
Registered: Sep 2003
Location: Dallas, Tx, USA
Distribution: Red Hat, Gentoo, Libranet
Posts: 98

Rep: Reputation: 16
Two thoughts:

First thing I'd check is when in the boot process it's being run. That spot where it says
Quote:
" [ ${NETWORKING} ="yes" ] || exit 0
is the only spot I could see that might exit without doing anything, yet give no error.

The first thing I tend to think of with problems like this is environment, because the environment during startup is like that with rsh or cron -- it's noticeably different than what you have when you're logged in.

From your comment about the paths being in the file, I suspect you already thought of that. I can't find anything else that it looks like they might have forgotten.


Second idea: Change your header line to "#!/bin/bash -x", to see what the program is doing. (That may or may not work, because, depending where it is in the boot process, the messages may get routed to the console or they may go off into never-never land.

You might also take off the redirection on the program startup ("$FETCHMAIL --daemon $TIME >/dev/null 2>&1".

Hope this helps,

CHL
 
Old 10-20-2003, 08:33 PM   #3
MaverickApollo
Member
 
Registered: Oct 2003
Distribution: Debian
Posts: 57

Original Poster
Rep: Reputation: 15
Quote:
" [ ${NETWORKING} ="yes" ] || exit 0

is the only spot I could see
I thought of that too, but am unsure on how Linux boots up. I tried removing that line, but it still dos'nt run on boot.

I'll try your other suggestions and watch the boot process and see what comes up.

If it dos'nt work I'll try stuffing it into rc.local, that may work!

Thanks

Mike

Last edited by MaverickApollo; 10-20-2003 at 08:38 PM.
 
Old 10-20-2003, 09:31 PM   #4
MaverickApollo
Member
 
Registered: Oct 2003
Distribution: Debian
Posts: 57

Original Poster
Rep: Reputation: 15
I got it working by changing the line:

$FETCHMAIL --daemon $TIME >/dev/null 2>&1

to $FETCHMAIL -f $FRC--daemon $TIME

because it could'nt find the .fetchmailrc file during the boot.

Thanks for your help

I am getting used to Linux, once you get out of the Windows way of thinking it really makes sense!



Michael.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
running perl scripts very system start abdul_zu Programming 16 09-26-2005 01:55 AM
Running scripts bhmsi Linux - Newbie 6 04-23-2005 06:05 PM
Running scripts moeru Linux - Software 10 07-02-2004 09:42 AM
Need help running scripts from scripts sdouble Linux - Newbie 3 05-31-2004 12:56 PM
Running scripts crash_zero Mandriva 5 04-19-2004 02:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration