Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to automatically run a script

Status
Not open for further replies.

horse123

Technical User
Oct 13, 2003
17
0
0
AU
Thank you all for my previous query about killing nonstpped processes.

Now I have a script with lines as follows:

ps -ef | grep cgiopac > cgio.ps
kill -9 `awk '$1==&quot;nobody&quot; && $3==1{print $2}' <cgio.ps`

How can I make it run automatically on the Unix server (AIX)? thanks in advance
 
Use cron:
Write and save your script as, say autokill.ksh
create an entry with crontab -e like :
00 08 * * * /mydir/autokill.ksh

Dickie Bird (:)-)))
 
Besides using cron job, you can do it like these:

cat yourscript.sh
#!/bin/ksh

#Kill processes every 5 mins
while :
do
ps -ef | grep cgiopac > cgio.ps
kill -9 `awk '$1==&quot;nobody&quot; && $3==1{print $2}' <cgio.ps`
sleep 300
done


Run it in background
nohup ./yourscript.sh &
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top