The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Background execution of a script Cameron Shell Programming and Scripting 2 10-03-2007 06:50 AM
Pb with script execution and variables Cecile AIX 1 09-15-2006 10:54 AM
pb with script execution Cecile UNIX for Dummies Questions & Answers 3 09-14-2006 11:37 AM
How to create file execution in KSH shell heru_90 Shell Programming and Scripting 4 06-23-2006 01:43 PM
execution of shell script malaymaru Shell Programming and Scripting 5 06-13-2005 10:49 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-17-2002
hoang hoang is offline
Registered User
  
 

Join Date: Apr 2002
Location: france
Posts: 19
Unhappy create a periodic execution of a script?

Hello every body
goal: create a script that control periodicly ( every 30 min ) if a process is already actif.

How can I do that?

thanks
  #2 (permalink)  
Old 04-17-2002
hugo_perez hugo_perez is offline
Registered User
  
 

Join Date: Apr 2002
Location: Argentine - that better than to eat meat and to drink wine (both Argentineans)?.
Posts: 132
1- create a simple Script ver_proc.sh (in a apropiate directory example /usr/local/scripts/varios or /usr/local/sbin/varios)
#!/bin/ksh
if [ $# -ne 1 ]
then
echo "Usage: $0 <proc_name>"
fi
PROC_NAME=$1
DAY=`date +"%Y%m%d"`
TIME=`date +"%Y/%m/%d %H:%M"`
CURR_SCRIPT=$0
if [ ! -d /var/log/$DAY ]
then
mkdir /var/log/$DAY
chmod 0755 /var/log/$DAY
fi
OUT=/var/log/$DAY/ps_$DAY.txt
if [ `ps -ef |grep $PROC_NAME |grep -v $CURR_SCRIPT |grep -v grep |wc -l ` -eq 1 ]
then
echo "$TIME `/usr/ucb/ps vax |grep $PROC_NAME |grep -v $CURR_SCRIPT |grep -v grep`" >> $OUT
else
ps -ef |grep $PROC_NAME |grep -v $CURR_SCRIPT |grep -v grep | while read linea
do
TIME=`date +"%Y/%m/%d %H:%M"`
echo "$TIME $linea" >> $OUT
done
fi

exit 0

2- chmod 0755 /usr/local/scripts/varios/ver_proc.sh

3- create a cron Job.
EDITOR=/usr/bin/vi ; export EDITOR
cron -e
# add the following line
00,30 * * * * [ -x /usr/local/scripts/varios/ver_proc.sh ] \
/usr/local/scripts/varios/ver_proc.sh <proc_name>

4- Modify the script at your flavor

Last edited by hugo_perez; 04-17-2002 at 11:59 AM..
  #3 (permalink)  
Old 04-17-2002
Kelam_Magnus's Avatar
Kelam_Magnus Kelam_Magnus is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2001
Location: DFW McKinney, TX,
Posts: 1,069
TEACH don't GIVE

I would swear that this is a typical homework question. Could someone please close this post?

FYI to everyone. Especially newbies!

Please ask for more information about what the user is trying to do before shooting your wad with the complete answer.

Remember that oldie but goodie? Not mine but a great lesson.

GIVE a man a fish and feed him for a day.
TEACH a man to fish and feed him for a lifetime.


  #4 (permalink)  
Old 04-17-2002
Neo's Avatar
Neo Neo is offline Forum Staff  
Administrator
  
 

Join Date: Sep 2000
Location: Asia Pacific
Posts: 6,832
Sound like a reasonable request
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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




All times are GMT -4. The time now is 08:13 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0