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
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.
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"
so how does it would look the complete command ?
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.
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
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.
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
The SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment.
Learn how to install the SAS Viya CLI and a few commands you may find useful in this video by SAS’ Darrell Barton.
Find more tutorials on the SAS Users YouTube channel.