Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Need help making a start/stop script... Post 302364995 by Scrutinizer on Sunday 25th of October 2009 05:34:36 AM
Old 10-25-2009
Hi phpfreak,

Here are a couple of off-the-cuff comments :
  • you need a PATH statement at the start of your script with the directories of all the external programs you are going to call from your script
  • call your own scripts and files you manipulate using absolute paths, not relative paths
  • depending on your intention either:
    - use & instead of && for background processing followed by a wait statement after the sleep statement
    - use && operator to start processes only when previous command succeeds but then loose the semicolons
  • do not use kill -9 unless you have to . Use kill first and then check. If not successful use other kill options or move directly on to kill -9.
  • use a colon ( : ) as an idle statement instead of echo>/dev/null or use [ "$A" != "$B" ]
  • You might want to brush up the mail command
  • You can not kill processes, you need process id's (pids). Either save those at the start of a process in a tmp file or distill it from ps -ef
  • You probably want to put all the statements either in a wrapper script or a function that contains the 45 second loop with the script calls, the comparison and the mail section and that you start perpetually in the background using:
    nohup /path/to/wrapperscript &
    The stop start script then just stops/starts/status checks that wrapper script
  • you can create a perpetual loop using
    Code:
    while : ; do
      your statements
    done

  • for the restart option you can use:
    Code:
    $0 stop; $0 start

  • Use exit statements to indicate error levels
Enough for now, have fun!

Last edited by Scrutinizer; 10-25-2009 at 06:41 AM..
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Start/Stop Script

I'm a newbie to the Unix world Help! I have to maintain a host of Sybase database servers sitting on Unix Sun Solaris 8...I've been tasked with finding/creating a way to auto start/stop Unix via unix commands, specifically when the Unix servers need to be restarted we want Sybase to start... (2 Replies)
Discussion started by: jjv1
2 Replies

2. UNIX for Dummies Questions & Answers

Making a Script to Start as a Service

Hi, I have a shell script t1.sh. on my solaris box. So, what are the steps required to make this script run as a Service, when the system re-starts. (for ex:- at run level 3). I know that I should use the rc.d folders. But I don't know the exact steps. Kindly explain, Thanks in... (3 Replies)
Discussion started by: S.Vishwanath
3 Replies

3. Shell Programming and Scripting

Start Stop Restart

I'm wondering how I should make a script that can start, stop, and restart another script. What I need to be able to do, is start and stop a perl script from the command line. The easiest way of doing this seems to be to have another script, starting and stopping the other script. I have BASH,... (7 Replies)
Discussion started by: Bakes
7 Replies

4. Shell Programming and Scripting

Help with stop/start Shell Script.

Hi All, I would like to develop a shell script for stop & start an application server (1-4) on Solaris box. Here are the user requirements for this task. 1. User will input the option which server they wish to stop. 2. Will clear cache files from specific location. 3. ... (1 Reply)
Discussion started by: venga
1 Replies

5. UNIX for Dummies Questions & Answers

Why does fibonacci sequence script stop making sense at 92nd iteration?

So, Just for practice, I wrote a simple fibonacci sequence script in bash. (03:08:02\$ cat fib #!/usr/bin/bash ret () { echo -ne "\n" sleep .5 } a=1 b=2 echo -n $a #1 A ret echo -n $b #2 B ret (8 Replies)
Discussion started by: DeCoTwc
8 Replies

6. Solaris

Stop/start script problem on Solaris-10

I have Big brother script, which start/stop Big Brother processes. Something got change on server and now I am not able to start/stop it. There is no change in script, as I compared it from other server. This service is being managed by bb user (group is also bb). root@tsazdq04:/#... (6 Replies)
Discussion started by: solaris_1977
6 Replies

7. Shell Programming and Scripting

Shell Script for Websphere MQ Queue Manager start/stop

Hello All, I am completely new to shell scripting. I had to write a script that starts and stop the queue manager in Websphere MQ. We are on Linux 64-bit patform. The script should stop the queue manager and all the processes related to websphere MQ. It should be a clean stop. Once the queue... (3 Replies)
Discussion started by: pady1224
3 Replies

8. Shell Programming and Scripting

Shell script to stop and start server

Hi, I need to create a shell script for automated server patching, with the following scenario: I have two Linux servers Primary and secondary. Server patching should start on Primary 1st and then secondary. 1st check both servers are up and running. Then stop primary and patching will... (1 Reply)
Discussion started by: rcroyal88
1 Replies
All times are GMT -4. The time now is 09:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy