- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello Friends
Can any one help me with the command to kill bjobs.
Lets says I want to kill all jobs that are 2 days older specific with the date,time and jobs that are running on different nodes.
I tried something like this bjobs -u all |grep "Oct 7" |grep "Oct 6" | egrep "node1|node2|node3" | awk '{print "bkill" $1}'
but looks like not working as expected....I want to kill all jobs specific to different date,time and executing node.
would appreciate for all your help
Thanks in Advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I would do this in two steps procedure
Step 1: Create a a text file that has the required job names or ID
Step 2:Create another script to read the text file and kill the jobs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your prompt response
Actually this would be time consuming manually doing, which am doing curretly.
am looking something with a single line command which can kill multiple jobs with different dates, time and executing nodes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
First of all, only the superuser can kill other user's jobs.
Next, this
grep "Oct 7" |grep "Oct 6"|
seems to be mutually exclusive, so there will be nothing left after the second pipe
Use the extended regular expression switch, and the pipe character (which does an OR in regex):
grep -E "Oct 7|Oct 6"
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
so how does it would look the complete command ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I would use a two-step approach like @Sajid01 suggested.
Start by running the
bjobs -u all
from a FILENAME PIPE, and fetch the result into a SAS dataset. Then you can do all the logic in a SAS program, and finally write the sellected process numbers to a textfile. A periodic superuser job can then pick up the file and do the kills. Or you call the kill script with sudo from the SAS program.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
That looks lengthy process, instead I can simply copy and paste id's on excel with filter and use bkill, but there is a single line command which does all what am requesting. I used to do it in previous company, but am not able to recollect it.
Its something like similar or may be below command
bjobs -u all |grep -v "Oct 7" |grep -v "Oct 6" | egrep "node1" | awk '{print "bkill" $1}' > bkill.ksh
or
bjobs -u all |grep node1 |grep "Oct 7" | awk '{print "bkill" $1}' > bkill.ksh
ksh -x bkill.ksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The two-step method lets me keep a record (in a dataset) of facts that led to the decision of killing. That makes the process maintainable and creates accountability.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
What about this (you could replace the echo commands with the actual bkill command).
#!/bin/bash timeago='2 days ago' bjobs -o "jobid submit_time" -u all -noheader | sed 's/ /'$'\t''/' | while IFS=$'\t' read -r jobid time do dtSec=$(date --date "$time" +'%s') taSec=$(date --date "$timeago" +'%s') if [ $dtSec -lt $taSec ] then echo "NOTE: Job $jobid was submitted over $timeago" echo "NOTE: You should run bkill $jobid" fi done
Greg Wootton | Principal Systems Technical Support Engineer
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
But am looking for the command not exactly 2 days before, jobs submitted before noon 1 day before all should be killed.
So there are multiple jobs with different dates and different times executing from different nodes
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Greg Wootton | Principal Systems Technical Support Engineer