Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checking process question

Status
Not open for further replies.

bendan

IS-IT--Management
Aug 20, 2004
5
0
0
AU
Hello all<br>
<br>
I can access several workstations in one LAN using one account.<br>
My problem is: How can I find out all the processes that I'm running<br>
on this network? I ask this is because sometimes I get complain from<br>
other students that I logged out but my program is still running on <br>
that machine.<br>
<br>
thanks<br>
<br>
PS I don't have root access on this network.
 
OK, couple of ways of doing this, depending on how you want to do it.<br>
<br>
If you're actually logged in to one of the network servers, then &quot;ps -u my_login_name&quot; will definitely list all your processes.<br>
<br>
If you're logged on to a different machine, you can just prefix the &quot;ps&quot; command as follows:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;rsh remote_machine_name -l my_login ps -u my_login<br>
<br>
This will execute the command on the remote server. You'll probably be asked for a password if using the &quot;rsh&quot; method. The password you enter is your password on the <i>remote</i> machine.<br>
<br>
If your network uses secure shell (ssh), then replace the &quot;rsh&quot; above with &quot;ssh&quot;.<br>
<br>
HTH.
 
Thanks AndyBo, it helps<br>
<br>
But is there a way to do it automaticly? coz there r over 60 machines:p. I'll have to rsh and type in password each time:(<br>
<br>
It would be great if u can give me some further help.<br>
<br>
Thanks again<br>
<br>
BenDan
 
There are a few ways to prevent the entering of your password every time, but a couple of them aren't favoured by sysadmins for security reasons. So, I'll get those out of the way first...<br>
<br>
1) Ask the sysadmins on each server to add your server to the file /etc/hosts.equiv. If the host your connecting from is listed, and the login name you are using on your local machine and the remote machine is the same, you won't need to enter a password.<br>
<br>
2) In your home directory on each server, create a file called &quot;<tt>.rhosts</tt>&quot; In this file, enter the name of your local server that you commonly use. If the login name on your local server is different to the remote server, then put a tab after your local server name followed by your local server login name.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;For example, your usual server is &quot;london&quot; and the login is &quot;mylogin&quot;. Remote server is &quot;newyork&quot; and the login is &quot;remlogin&quot;. Login to &quot;newyork&quot; as &quot;remlogin&quot; and create &quot;<tt>.rhosts</tt>&quot; in your home directory. Add the following line:<br>
<tt><br>
london&nbsp;&nbsp;&nbsp;&nbsp;mylogin<br>
</tt><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;This should then allow you to run <tt>rsh</tt> from &quot;london&quot; to &quot;newyork&quot; without entering your password.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;Warning: Your sysadmins may run a check on a regular basis that removes <tt>.rhosts</tt> files, as they can compromise security. Probably worth checking before creating <tt>.rhosts</tt> on 60 servers. ;^)<br>
<br>
3) Persuade your sysadmins to install <tt>ssh</tt> onto the servers. ssh uses a public key exchange between the server and client for authentication.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;However, there may be problems with installing this. I've heard of situations where the <tt>ssh</tt> packets flowing around the network can cause some servers to stop talking to the rest of the network. This would probably mean installing <tt>ssh</tt> onto 60 servers in one fell swoop... Not a difficult task, but not exactly trivial , either! :)<br>
<br>
As far as the automatic part goes, you could ask the sysadmins to give you persmission to run cron on your local server (&quot;london&quot; in the previous example.). You could then set up a cron job to run a shell script, say, every five minutes to do the &quot;ps&quot; on each remote server.<br>
<br>
The shell script might look like the following. (&quot;\&quot; indicates that a line has been split for readability. Lines split in this way may be entered as one line in the script.)<br>
<tt><br>
#!/bin/sh<br>
MYLOGFILE=/path/to/log/file<br>
<br>
# Create a new logfile.<br>
&gt;$MYLOGFILE<br>
<br>
# Loop around each server, checking for jobs run by me.<br>
for server in london newyork paris tokyo<br>
do<br>
&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;My processes on $server&quot; &gt;&gt;$MYLOGFILE<br>
&nbsp;&nbsp;&nbsp;&nbsp;rsh $server -l my_login_name ps -fu my_login_name \<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&gt;&gt;$MYLOGFILE<br>
done<br>
</tt><br>
<br>
The crontab entry would then look like:<br>
<tt><br>
# Run my process log command every five minutes, between 8am<br>
# and 6pm.<br>
0,5,10,15,20,25,30,35,40,45,50,55 8-18 * * * /path/to/script<br>
</tt><br>
<br>
Doing it this way, $MYLOGFILE as named in the script will always show what is running on the servers up to 5 minutes ago. I'd suggest manually running the script first, to see how long it takes to run. If it takes more than 5 minutes, then make the interval in the crontab larger. eg, set the minutes to be &quot;0,10,20,30,40,50&quot;.<br>
<br>
For more info on cron, look at &quot;<tt>man cron</tt>&quot; and &quot;<tt>man crontab</tt>&quot;. There are also man pages on rhosts, hosts.equiv, rsh, rcp, and rlogin. If installed, there will also be man pages for ssh.<br>
<br>
Hope this helps :)
 
Thank u very much!! AndyBo<br>
<br>
It does help a lot(60 passwords:)<br>
<br>
<br>
<br>
BenDan<br>
<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top