Answer the question
In order to leave comments, you need to log in
How to use awk to calculate the date difference without losing the whole "table"?
The command displays which tasks are currently running and when these tasks started.
# bjobs -u all -o "jobid user stat SUBMIT_TIME"
JOBID USER STAT SUBMIT_TIME
16188 chemicalinorg_serov RUN Aug 29 12:04
16286 aerohydromech RUN Sep 10 11:35
16287 ifmbmdcam RUN Sep 10 16:03
16283 KozlovaAS RUN Sep 8 13:32
16307 chemicalorg RUN Sep 13 14:37
16306 KozlovaAS RUN Sep 13 14:31
#DATENOW=$(date +%m:%d | awk -F ":" '{print ($1*30+$2)}')
#echo $DATENOW
284
# bjobs -u all -o "jobid user stat SUBMIT_TIME" | tail -n +2 | awk ' (system("date +%m:%d --date=\""$4 $5"\""))' | awk -F ":" '{print ($1*30+$2)}'
269
280
280
278
283
283
284
# bjobs -u all -o "jobid user stat SUBMIT_TIME" | tail -n +2 | awk ' (system("date +%m:%d --date=\""$4 $5"\""))' | awk -F ":" '(('$DATENOW'-($1*30+$2)) > 10)'
08:29
Answer the question
In order to leave comments, you need to log in
The date can still be transformed in this way, perhaps it will suggestdate -d "12:04 Aug 29" +%s
They said correctly above - convert the date to a timestamp and perform any comparisons.
For example, you can do this:
while read
do
SUBMIT_DATE=$(echo $REPLY | awk -F "RUN" '{print $2}')
declare -i DAYS=($(date "+%s")-$(date -d "$SUBMIT_DATE" "+%s"))/3600/24
if ; then
echo "This job was executed more than 10 days ago: $REPLY"
fi
done <yourcommand
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question