Results 1 to 7 of 7
|
Enjoy an ad free experience by logging in. Not a member yet? Register.
|
|
-
12-13-2004 #1
- Join Date
- Dec 2004
- Posts
- 4
Simple scripting question from newbie
I have a process that frequently defuncts. I would like to write a script to stop it and start it at a set time everyday. To stop and start the process I used the following lines from the command line.
/etc/rc.d/init.d/agent.init stop
/etc/rc.d/init.d/agent.init start
when I try to create a script that I could run from cron I get the following error.
Usage: agent.be { start | stop }
I have also tried the follwoing commands without success.
killall agent.be
./etc/bkupexec/agent.be
Here is a copy of the agent.init script
Code:#!/bin/sh DESTDIR=/etc/bkupexec if [ ! -d $DESTDIR ] then # Backup Exec Agent not installed exit fi CMD="$1" case "$CMD" in 'start') if [ -x $DESTDIR/agent.be ] then $DESTDIR/agent.be -c $DESTDIR/agent.cfg 2>$DESTDIR/agent.log & fi ;; 'stop') # stop the Agent daemons if [ -f /bin/grep ] then pid=`/bin/ps -e | /bin/grep agent.be | /bin/sed -e 's/^ *//' -e 's/ .*//'` else pid=`/usr/bin/ps -e | /usr/bin/grep agent.be | /usr/bin/sed -e 's/^ *//' -e 's/ .*//'` fi if [ "${pid}" != "" ] then if [ -f /bin/kill ] then /bin/kill ${pid} else /usr/bin/kill ${pid} fi fi ;; *) echo "Usage: agent.be { start | stop }" ;; esac
***Mod Edit: Put code into code brackets. Please use BBCode to format your posts in the future.***
-
12-14-2004 #2
- Join Date
- Dec 2004
- Posts
- 12
Hi
From my command line your script works well. Could you post the lines from your crontab which invoke the script ? It seems that your arguments may not be reaching the script.
Spook
-
12-14-2004 #3
- Join Date
- Dec 2004
- Posts
- 4
OK, the crontab entry is
0 16 * * * /etc/dansguardian/bkupexec_agent_restart
this is just a file I created with the two lines
/etc/rc.d/init.d/agent.init stop
/etc/rc.d/init.d/agent.init start
in it.
-
12-14-2004 #4
- Join Date
- Dec 2004
- Posts
- 12
Hmm, OK I had asumed that the code you posted was agent.be
It seems like the agent.be script which you call in the start method of the case statement requires a start or stop parameter which you are not supplying:
Code:$DESTDIR/agent.be -c $DESTDIR/agent.cfg 2>$DESTDIR/agent.log &
Code:echo "Usage: agent.be { start | stop }"
Code:echo "Usage: agent.init { start | stop }"
Cheers
Spook
-
12-14-2004 #5
- Join Date
- Dec 2004
- Posts
- 4
Alright, that worked. The script is successfully stopping and starting the process. Thank You very much!
-
12-14-2004 #6
- Join Date
- Dec 2004
- Posts
- 4
OK, I am a goober. Obviously the echoi would'nt have made a difference, un less it means something different than a windows/dos environment. For what ever reason this script is now working. I have changed nothing on the system since I first wrote in asking for help but it seems to really be working now. Thank you for all your help!!
-
12-14-2004 #7
- Join Date
- Dec 2004
- Posts
- 12
Hi
You're welcome!
I suggested changing the echo just so it was clear where the actual error message came from (the error generated by agent.init would have said agent.be)
I'm glad you got things working. Isn't it a bummer when it just suddenly works and you cant see why it didn't in the first place
Cheers
Spook