nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Shell script to kill process Automatically after 3 days

This is a discussion on Shell script to kill process Automatically after 3 days within the Shell scripting forums, part of the Development/Scripting category; hello i'm on Debian I need script who automaticly will kill all (eggdrop,psybnc) processes on 3 days or 1 week....


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

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 01-12-2007, 07:12 PM
Junior Member
User
 
Join Date: Jan 2007
Posts: 6
Rep Power: 0
darknet
Default Shell script to kill process Automatically after 3 days

hello i'm on Debian

I need script who automaticly will kill all (eggdrop,psybnc) processes on 3 days or 1 week.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-13-2007, 12:24 AM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Here is sample script

Code:
#!/bin/bash
# Days ago
DAYS="3"
PROCS="eggdrop|psybnc"

# Old date
AGO=$(date --date="$DAYS days ago" +"%b %d")

# Get pids 
PIDS=$(ps eaxo bsdstart,cmd,pid | egrep "^$AGO"' | egrep "$PROCS" | awk '{ print $4}')

# Now kill em
echo "Killing $PROCS process created $AGO days ago..."
kill -9 $PIDS
Changes DAYS and PROCS variable as per your setup and requirements. Test it and let me know...
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #3 (permalink)  
Old 01-13-2007, 06:23 PM
Junior Member
User
 
Join Date: Jan 2007
Posts: 6
Rep Power: 0
darknet
Default

thanks a lot
Reply With Quote
  #4 (permalink)  
Old 12-21-2007, 11:46 PM
Junior Member
User
 
Join Date: Dec 2007
My distro: Debian
Posts: 1
Rep Power: 0
almaap is on a distinguished road
Smile Minutes?

Hey nixcraft,

I need almoust the same script but i have to kill process after 2 minutes.
working system is suse 9.0!

May you can help me out with some lines?

thanks for all your help!

best regards
al ma ap
Reply With Quote
Reply

Bookmarks


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 On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Run mv command from ftp shell script subin Shell scripting 6 05-02-2008 10:44 AM
Killing of a process and send a mail if the process doesnot come up within 2 minutes Prince89 Shell scripting 1 02-11-2008 01:39 PM
Shell Script to Automatically Delete a File via Cron Job kakarla Shell scripting 2 01-29-2008 09:54 AM
kernel panic -not syncing attempt to kill init jhn_daz@yahoo.com Linux software 3 11-26-2007 05:16 PM
writing a shell script to find out my shell name jaymob123 Shell scripting 1 10-08-2007 01:36 AM


All times are GMT +5.5. The time now is 08:33 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

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