- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Help with C Shell Script - Automatically Kill proc...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-05-2003 11:51 AM
тАО05-05-2003 11:51 AM
Help with C Shell Script - Automatically Kill process
I need some help writing a script. I need
to find all processes with the words voucher
and then find all those user and send them
a wall message (to just those users)" to log out in 2 minutes" and then
wait 2 minutes and then kill all those tasks as super user.
I need to kill the ppid and pid's. I do not want to kill pid 1, and sometime these processes attach to pid 1.
I then want to put this on the menu for my accountant to execute whenever she wants (password protected of course).
Thanks,
Laurie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-05-2003 12:14 PM
тАО05-05-2003 12:14 PM
Re: Help with C Shell Script - Automatically Kill process
# ps -ef | while read a b c d e f
> do
> echo kill $b
> done
This is the 'preview' version. When ready remove the 'echo'.
> kill $b
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-05-2003 12:42 PM
тАО05-05-2003 12:42 PM
Re: Help with C Shell Script - Automatically Kill process
I first kill -15 to give the application a chance to recover itself, then I do a kill -9 for those that didn't die nicely. I also take the oppurtunity to delete any run away -ksh sessions.
I send the output of this script to a text file which I can review if need be.
HTH
-- Rod Hills
#!/usr/bin/ksh
# -- kick off production users prior to backup
echo "\07Production AVANTE backup process starts in 2 minutes\07" | /usr/sbin/wall
echo "System will be unavailable from 9:05 to 10:00 tonight" | /usr/sbin/wall
sleep 60
echo "\07Production AVANTE coming down in 60 seconds...\07" | /usr/sbin/wall
sleep 30
echo "\07Production AVANTE coming down in 30 seconds...\07" | /usr/sbin/wall
sleep 30
echo "\07Production AVANTE Halting !! Come back in 10 min\07" | /usr/sbin/wall
echo "Kill Soft Pass ..."
ps -ef | awk '$8=="UV"{print $0 ; system("kill -15 " $2)}'
sleep 30
echo "Kill Hard Pass ..."
ps -ef | awk '$8=="UV"{print $0 ; system("kill -9 " $2)}'
sleep 15
echo "Kill run away ksh Pass ..."
ps -ef | awk '$8=="-ksh" && $3=="1"{print $0 ; system("kill -9 " $2)}'
sleep 15
echo "Kill Proof ..."
ps -ef | awk '$8=="UV"{print $0}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-05-2003 12:46 PM
тАО05-05-2003 12:46 PM
Re: Help with C Shell Script - Automatically Kill process
I first kill -15 to give the application a chance to recover itself, then I do a kill -9 for those that didn't die nicely. I also take the oppurtunity to delete any run away -ksh sessions.
I send the output of this script to a text file which I can review if need be.
HTH
-- Rod Hills
#!/usr/bin/ksh
# -- kick off production users prior to backup
echo "\07Production AVANTE backup process starts in 2 minutes\07" | /usr/sbin/wall
echo "System will be unavailable from 9:05 to 10:00 tonight" | /usr/sbin/wall
sleep 60
echo "\07Production AVANTE coming down in 60 seconds...\07" | /usr/sbin/wall
sleep 30
echo "\07Production AVANTE coming down in 30 seconds...\07" | /usr/sbin/wall
sleep 30
echo "\07Production AVANTE Halting !! Come back in 10 min\07" | /usr/sbin/wall
echo "Kill Soft Pass ..."
ps -ef | awk '$8=="UV"{print $0 ; system("kill -15 " $2)}'
sleep 30
echo "Kill Hard Pass ..."
ps -ef | awk '$8=="UV"{print $0 ; system("kill -9 " $2)}'
sleep 15
echo "Kill run away ksh Pass ..."
ps -ef | awk '$8=="-ksh" && $3=="1"{print $0 ; system("kill -9 " $2)}'
sleep 15
echo "Kill Proof ..."
ps -ef | awk '$8=="UV"{print $0}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2003 02:06 AM
тАО05-06-2003 02:06 AM
Re: Help with C Shell Script - Automatically Kill process
1.- The wall command up to HP-UX 10.20 is for groups not users, so the first think you must do is to create a group for each user, so each group has only one user. (see man wall)
2.- Create 2 scripts, you can put them in /usr/local/bin or something similar. The first one is only one line that calls the other one.
first script:
su -c /usr/local/bin/2nd_script
This way the root password will be demanded to execute the second script.
I attach you this 2nd script.
Be careful to put the chmod 755 to the scripts to make it executables.
Edit the script and make the correct changes, mainly in the user groups initialization and the message sent to the users.
3.- To put in the screen menu you must edit the file in home users ~/.dt/dtwmrc and add an entry in the Root Menu.
Frank.