nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

Script to kill PS and Start Again

This is a discussion on Script to kill PS and Start Again within the Shell scripting forums, part of the Development/Scripting category; Hello Nixcraft!!! Learning Shell Scripting. Bear with me. And I attempted to search for the answer prior to posting. I ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 29-05-2009, 12:47 AM
jaysunn's Avatar
Powered By Linux
User
 
Join Date: Apr 2009
Location: 41.332032,-73.089775
OS: RHEL - OSX
Scripting language: BASH - Learning Ruby
Posts: 604
Thanks: 61
Thanked 80 Times in 72 Posts
Rep Power: 10
jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold
Default Script to kill PS and Start Again

Hello Nixcraft!!!

Learning Shell Scripting. Bear with me. And I attempted to search for the answer prior to posting.

I am currently working on a bash shell script that will update a configuration change to a servers swatch logwatch application. The issue that appears to happen is I am successful in the termination piece of the puzzle. However the command that I issue from the command line in the shell does not successfully start the perl Processes again. I tried a sleep command before the init scripts and I was unsuccessful. Please shed some light on this:
Code:
# grep for Process ID and create variable
#
for proc in `ps -ef | grep swatch | awk '{print $2}'`; do

kill -9  $proc ; done
# 
#
# Issue start command for perl swatch processes to run
#
swatch -c /var/log/swatch/.swatchrc.apache --script-dir=/var/log/swatch -t /usr/local/apache/logs/radio24_error_log &

swatch -c /var/log/swatch/.swatchrc.messages --script-dir=/var/log/swatch -t /var/log/messages &
Reply With Quote
  #2 (permalink)  
Old 29-05-2009, 04:56 AM
Junior Member
User
 
Join Date: Feb 2008
OS: .
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
unSpawn is on a distinguished road
Default

Maybe it isn't the problem but how about handing commands off to 'at'? As in 'echo "swatch -c /var/log/swatch/.swatchrc.apache --script-dir=/var/log/swatch -t /usr/local/apache/logs/radio24_error_log"|/usr/bin/at now'? If something goes wrong an email will be sent to the at user which may contain leads for resolving errors.

BTW 'for proc in `ps -ef | grep swatch | awk '{print $2}'`; do kill -9 $proc ; done' can prolly be written more tersely as 'pkill -9 swatch'.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Shell script to kill process Automatically after 3 days darknet Shell scripting 4 02-11-2009 12:40 AM
Script To Kill process if time and memories of more than 30% lliriK Shell scripting 9 28-04-2009 12:43 AM
shell script to start a service asim.mcp Shell scripting 6 28-07-2008 12:18 PM
kernel panic -not syncing attempt to kill init jhn_daz@yahoo.com Linux software 3 26-11-2007 04:16 PM
start up and stop the running script mala_un Shell scripting 9 26-07-2006 07:10 AM


All times are GMT +5.5. The time now is 06:06 AM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38