UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 29th, 2011, 07:02 AM
ravidulla ravidulla is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2011
Posts: 5 ravidulla User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 59 sec
Reputation Power: 0
Killing of inactive sesions older than a day

Appreciate your help for the below.
I have to kill the Pid`s where Stime greater than previous day.

File data is like the below:

DSnum Uid Pid Ppid C Stime Tty Time Command
53086 dsadm 241812 1667206 0 Sep 27 - 0:00 dsapi_slave 7 6 0
36690 dsadm 1568848 1958134 0 05:50:29 - 0:00 dsapi_slave 7 6 0
36544 dsadm 1700058 1544214 0 Sep 26 - 0:01 dsapi_slave 7 6 0
36612 dsadm 1831054 1933432 0 Sep 26 - 0:00 dsapi_slave 7 6 0
61134 dsadm 1446106 1441968 0 Sep 26 - 0:01 dsapi_slave 7 6 0
44932 dsadm 1364010 1466594 0 Sep 26 - 0:00 dsapi_slave 7 6 0
52914 dsadm 1618156 1097902 0 Sep 23 - 0:00 dsapi_slave 7 6 0
44870 dsadm 1298540 540682 0 Sep 23 - 0:00 dsapi_slave 7 6 0
61178 dsadm 1642658 1634464 0 Sep 22 - 0:01 dsapi_slave 7 6 0


I have tried with sed command like

sed -n '/Aug/,/Sep/p' file_name,grep "Aug" file_name etc., but couldn`t able to fulfill \
my requirement.

Could you please help me on this?
-Ravi

Reply With Quote
  #2  
Old October 1st, 2011, 02:56 PM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is online now
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,363 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 10 h 24 m 40 sec
Reputation Power: 383
use gawk

Try one of these untested pipelines:

Code:
gawk '$6~/^[A-Z]/ {print "kill -9 " $3}' file | bash

ps -your -funny -arguments | gawk '$6~/^[A-Z]/ {print "kill -9 " $3}' file | bash



When I'm doing this sort of thing I usually test first by putting "echo" just before "kill"

Reply With Quote
  #3  
Old October 3rd, 2011, 07:36 AM
ravidulla ravidulla is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2011
Posts: 5 ravidulla User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 59 sec
Reputation Power: 0
Thanks a lot David Lambert for your response.

awk function is working in my unix macine but awk function throwing error like 'gawk not found'.

I have used the below command
awk '$6~/^[A-Z]/ {print "echo " $3}' temp.txt

but it is not dispalying first row and output is like the below.
echo Uid
echo 1700058
echo 1831054
echo 1446106
echo 1364010
echo 1618156
echo 1298540
echo 1642658

even though I have sorted date filed but same problem.
Plesae help me.
Quote:
Originally Posted by b49P23TIvg
Try one of these untested pipelines:

Code:
gawk '$6~/^[A-Z]/ {print "kill -9 " $3}' file | bash

ps -your -funny -arguments | gawk '$6~/^[A-Z]/ {print "kill -9 " $3}' file | bash



When I'm doing this sort of thing I usually test first by putting "echo" just before "kill"

Reply With Quote
  #4  
Old October 3rd, 2011, 10:29 AM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is online now
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,363 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 10 h 24 m 40 sec
Reputation Power: 383
Change the condition.

Code:
$ awk '/^[1-9]/&&($6~/^[A-Z]/){print"echo kill -9",$3}' data | bash
kill -9 241812
kill -9 1700058
kill -9 1831054
kill -9 1446106
kill -9 1364010
kill -9 1618156
kill -9 1298540
kill -9 1642658


In this case the {action} happens only when the head of line starts with [1-9] and field 6 contains a first character of [A-Z] . Test against your current processes. When satisfied, remove echo.

I cannot explain the exclusion of process 241812 based on appearances. You would have to upload your data file. Recreate your data file by cut-n-paste from this forum to fix the trouble you demonstrated.

Last edited by b49P23TIvg : October 3rd, 2011 at 10:38 AM. Reason: finish business

Reply With Quote
  #5  
Old October 4th, 2011, 01:22 PM
epanagio's Avatar
epanagio epanagio is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2003
Posts: 660 epanagio User rank is Second Lieutenant (5000 - 10000 Reputation Level)epanagio User rank is Second Lieutenant (5000 - 10000 Reputation Level)epanagio User rank is Second Lieutenant (5000 - 10000 Reputation Level)epanagio User rank is Second Lieutenant (5000 - 10000 Reputation Level)epanagio User rank is Second Lieutenant (5000 - 10000 Reputation Level)epanagio User rank is Second Lieutenant (5000 - 10000 Reputation Level)epanagio User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 5 h 32 m 17 sec
Reputation Power: 94
git: writing files

Oops. I posted in the wrong place. SORRY!
I am new to git and I have installed a client on two computers and I am able to manage changes to the git repository from either computer. I see the diffs and I am happy so far. I have a website that we manage the data through git but my question has to do with writing the data from the git repository back to public_html. Can I write the data from the git to public_html using git or do I have to write a bash script myself that will do that?

Thanks,
__________________
Evan

Reply With Quote
  #6  
Old October 11th, 2011, 07:02 AM
ravidulla ravidulla is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2011
Posts: 5 ravidulla User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 59 sec
Reputation Power: 0
DataStage Job Export from unix

Its working with the below code now.

ps -u dsadm | awk '$6~/^[A-Z]/ {print "kill -9 " $3}' ActiveSessions.txt.

Thanks a lot for your Help David.

One more help please...

I would like to take backup(export) of DataStage jobs(not all jobs) which has modified yesterday(incremental backup).

by using DsExport command we can take back up of particular job or a project.But how can we export by last modified date?

Appreciate your help on this. Thanks in advance.



Quote:
Originally Posted by b49P23TIvg
Code:
$ awk '/^[1-9]/&&($6~/^[A-Z]/){print"echo kill -9",$3}' data | bash
kill -9 241812
kill -9 1700058
kill -9 1831054
kill -9 1446106
kill -9 1364010
kill -9 1618156
kill -9 1298540
kill -9 1642658


In this case the {action} happens only when the head of line starts with [1-9] and field 6 contains a first character of [A-Z] . Test against your current processes. When satisfied, remove echo.

I cannot explain the exclusion of process 241812 based on appearances. You would have to upload your data file. Recreate your data file by cut-n-paste from this forum to fix the trouble you demonstrated.

Reply With Quote
  #7  
Old October 11th, 2011, 09:19 AM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is online now
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,363 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 10 h 24 m 40 sec
Reputation Power: 383
find -mtime

Read the find man page. It's long. Ask for more help if you get a command that's close. I always have trouble understanding the double negatives and time formats. (The mtime will be argument will be +1, -1, or 1 I'm thinking.) The file name is usually important for my applications, so I include the -name argument. The command will be something like:

to list the files:

Code:
$ find path/to/top/of/interesting/tree -mtime 1 -name 'shell*glob[a-q]pattern.db?' -print

to use them directly (-print for your pleasure, otherwise useless):
Code:
$ find path -mtime 1 -name 'pattern' -print  -exec DsExport -DsExport args {} \;


Hmm, you might be able to solve your original question with a find /proc command.

Reply With Quote
  #8  
Old October 20th, 2011, 05:43 AM
ravidulla ravidulla is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2011
Posts: 5 ravidulla User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 59 sec
Reputation Power: 0
Problem with junk characters while rediercting the file

Greetings David!

I am having problem while redirecting the file.

bin/uv -admin -info > SessionInfo.txt

when giving above command I got data like the below in the file.

Details for DataStage Engine release 7.5.3.1 instance "ade"
===============================================================================
Install history : Installed by dsadm (admin:dsadm) on: Jul 14 2010 10:55:13
Instance tag : ade
Engine status : Running w/active nls
Engine location : /vol01/home/dsadm/Ascential/DataStage/DSEngine
Binary location : /vol01/home/dsadm/Ascential/DataStage/DSEngine/bin
Impersonation : Enabled
Administrator : dsadm
Autostart mode : enabled
Autostart link(s) : /etc/ds.rc
Startup script : /vol01/home/dsadm/Ascential/DataStage/DSEngine/sample/ds.rc
Cache Segments : 0 active
User Segments : 26 active

19 printer segments abandoned!
7 phantom printer segments!
DSnum Uid Pid Ppid C Stime Tty Time Command
44960 dsadm 1560578 1568816 0 04:42:47 - 0:00 dsapi_slave 7 6 0
61160 dsadm 1675442 1761442 0 Oct 18 - 0:00 dsapi_slave 7 6 0
61276 dsadm 1314900 1458312 0 04:41:08 - 0:00 dsapi_slave 7 6 0
65198 dsadm 1769702 1745026 0 04:32:29 - 0:00 dsapi_slave 7 6 0
65296 dsadm 1409178 1728522 0 Oct 19 - 0:00 dsapi_slave 7 6 0
44744 dsadm 1462496 1683488 0 Oct 19 - 0:00 dsapi_slave 7 6 0
36694 dsadm 913524 1753272 0 07:34:35 - 0:00 dsapi_slave 7 6 0


But some underline characters displaying (^[[4m) in the file when checking in vi mode which I need to remove with some command(not in vi mode).

Please check the below file and help me with a command to remove those characters.

Details for DataStage Engine release 7.5.3.1 instance "ade"
===============================================================================
Install history : Installed by dsadm (admin:dsadm) on: Jul 14 2010 10:55:13
Instance tag : ade
Engine status : Running w/active nls
Engine location : /vol01/home/dsadm/Ascential/DataStage/DSEngine
Binary location : /vol01/home/dsadm/Ascential/DataStage/DSEngine/bin
Impersonation : Enabled
Administrator : dsadm
Autostart mode : enabled
Autostart link(s) : /etc/ds.rc
Startup script : /vol01/home/dsadm/Ascential/DataStage/DSEngine/sample/ds.rc
Cache Segments : 0 active
User Segments : 26 active

19 printer segments abandoned!
7 phantom printer segments!
^[[4m DSnum Uid Pid Ppid C Stime Tty Time Command
^[[m 44960 dsadm 1560578 1568816 0 04:42:47 - 0:00 dsapi_slave 7 6 0
61160 dsadm 1675442 1761442 0 Oct 18 - 0:00 dsapi_slave 7 6 0
61276 dsadm 1314900 1458312 0 04:41:08 - 0:00 dsapi_slave 7 6 0
65198 dsadm 1769702 1745026 0 04:32:29 - 0:00 dsapi_slave 7 6 0
65296 dsadm 1409178 1728522 0 Oct 19 - 0:00 dsapi_slave 7 6 0
44744 dsadm 1462496 1683488 0 Oct 19 - 0:00 dsapi_slave 7 6 0
36694 dsadm 913524 1753272 0 07:34:35 - 0:00 dsapi_slave 7 6 0
~

Thanks in Advance..!

Ravi


Quote:
Originally Posted by b49P23TIvg
Try one of these untested pipelines:

Code:
gawk '$6~/^[A-Z]/ {print "kill -9 " $3}' file | bash

ps -your -funny -arguments | gawk '$6~/^[A-Z]/ {print "kill -9 " $3}' file | bash



When I'm doing this sort of thing I usually test first by putting "echo" just before "kill"

Reply With Quote
  #9  
Old October 20th, 2011, 11:05 AM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is online now
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,363 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 10 h 24 m 40 sec
Reputation Power: 383
I learned more of bash!

$ echo The $'\e[4munderlined\e[m' word
The underlined word

$ echo The $'\e[4munderlined\e[m' word | sed $'s/\e[[][0-9;]*m//g'
The underlined word


Put this sed command into your command pipeline.

First line demonstrates ANSI underline and the bash feature new to me--- $'escape sequence substitution' .

Second line demonstrates removal of ^[[12;23;42;4;1;2m
to clean away color, bold, flash, invert...

Last edited by b49P23TIvg : October 20th, 2011 at 11:07 AM. Reason: surplus hyphen removal

Reply With Quote
  #10  
Old October 24th, 2011, 04:58 AM
ravidulla ravidulla is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2011
Posts: 5 ravidulla User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 59 sec
Reputation Power: 0
Thanks David for your response.

I have tried the command which you have sent.But its displaying like the below and sed command is not working good.

The $\underlined\ word

I tried with below command and displaying the underlined word.

echo "\033[4m This is underlined text.\033[0m \n Word"

This is underlined text.
Word

and while using
> echo "\033[4m This is underlined text.\033[0m \n lets see and test" > file.txt

> sed 's/[\^[[[0-9;]*m//g' a > file1.txt

while open file1.txt in vi mode its displaying like the below still:

^[ This is underlined text.^[
Word

I have to remvoe ^[ character too from the above file.
I am using ksh in unix.

Please help me.Thanks in advance.




Quote:
Originally Posted by b49P23TIvg
$ echo The $'\e[4munderlined\e[m' word
The underlined word

$ echo The $'\e[4munderlined\e[m' word | sed $'s/\e[[][0-9;]*m//g'
The underlined word


Put this sed command into your command pipeline.

First line demonstrates ANSI underline and the bash feature new to me--- $'escape sequence substitution' .

Second line demonstrates removal of ^[[12;23;42;4;1;2m
to clean away color, bold, flash, invert...

Reply With Quote
  #11  
Old October 24th, 2011, 07:57 AM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is online now
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,363 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 10 h 24 m 40 sec
Reputation Power: 383
Look closely now

Code:
$ echo The $'\e[4munderlined\e[m' word
$ echo The $'\e[4munderlined\e[m' word | sed $'s/\e[[][0-9;]*m//g'


I did not present "\033[blah blah blah"

I DID present $'\e[4m underlined text \e[m'


Look for
Quote:
3.1.2.4 ANSI-C Quoting
in http://www.gnu.org/s/bash/manual/bash.html#Shell-Parameter-Expansion

explanation of $'text'

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Killing of inactive sesions older than a day

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap