get the server's hostname


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers get the server's hostname
# 1  
Old 06-29-2009
get the server's hostname

i read that if i issue :

cat /etc/sysconfig/network > textfile

i will be able to determine the hostname of the server that my linux workstation is connected to.

but there are several other lines outputted that i do not need. i just need the hostname part.

is there any other unix command i can use? i tried hostname, hostid but they give the name of the workstation, not the server's name.

thanks for any leads
# 2  
Old 06-29-2009
What exactly are, for you, the differences between "host name" and "server name"?

"hostname" will give you the machines host name. "hostname -f" will give you the machines FQDN (but this is Linux only). If you mean the DNS entry for an IP used by the machine, you could use "dig -x <IP>" to get that.
# 3  
Old 06-29-2009
hostname, server's hostname

thanks pludi for quick reply.

i have to monitor several linux workstations connected to a linux server.

i intend to issue cron jobs in each of the workstations to get the processes running and output the results to a textfile daily.

so for every 30 minutes, cron job something like :
0,30 * * * * * ... ps c -FC "firefox-bin,soffice.bin, ..." >> textfile.txt

the textfile.txt is to contain the workstation's hostname as part of the filename which i can get by issuing hostname at the workstation prompt.

at the end of the day, the workstation has to copy that daily file to a subdirectory in the server. another cron job that i think will need the server's hostname this time. something like :

cp textfile.txt serverhostname/assigned/directory/
(or ssh, ftp, scp whichever will be applicable, please suggest.)

at end of the day, i should have 10 daily files coming from each of the 10 workstations at the serverhostname/assigned/directory/

as each of the textfile.txt contains the name of the workstation it came from, i can write a program to track which workstations are used more often and at what peak times for the processes being monitored from these log files.

this is for the high school administrators/lab manager who want to monitor what the computers in their internet lab are being used for and at what times.

i was worried that if the serverhostname is changed by the sysad at the server, my cron tasks and scripts will not run if i hardcode the serverhostname, thus my need to find it out from wherever (e.g. cat /etc/sysconfig/network > something.txt).

thanks, just a newbie here.
better leads how to accomplish above will be appreciated.

(i also have another problem -- how to make the ps command accept the "watched executables" from a csv file that can later be expanded instead of hardcoding each of the additional executables in the ps statement)
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Hostname -f hostname: Unknown host

deleted (0 Replies)
Discussion started by: hce
0 Replies

2. Red Hat

After umount -lf: kernel: nfs: server HOSTNAME not responding, timed out

Greetings! I'm testing a failover solution for NFSv4 on RHEL6 with latest updates. My script umounts (umount -lf /share) the faulty NFS share if it sees that's hanging on the client (the NFS daemon is down on the NFS server) and it mounts the share from another healthy NFS server. Sometimes... (4 Replies)
Discussion started by: Arsene Lupen
4 Replies

3. Solaris

2 hostname in one server

Hi, We have one server originally named <SERVERA>. Now we plan to put another network card & add another hostname <SERVERB>. Later, we will need to change hostname from <SERVERB> to <SERVERC>. I know that we need to plumb a new ip & add to /etc/hosts & /etc/hostname.<interface>. Is there... (2 Replies)
Discussion started by: beginningDBA
2 Replies

4. Solaris

my sun solaris 10 cannot ping and nslookup other server using hostname.

hi.... i have sun solaris 10 server, fedora 10, and Windows Server.. i cant ping my sun solaris 10, fedora 10 and Windows Server using hostname (etc: ping winserver.bengkel2.com), but i can ping all using IPV4 and IPV6 address.. can u give some suggestion to solve my problem or some idea to... (3 Replies)
Discussion started by: izuan_7657
3 Replies

5. Emergency UNIX and Linux Support

HP UX - ILO Console hostname different than Machine Hostname...

Hi All, So we added a new HP-UX 11.31 machine. Copied OS via Ignite-UX (DVD)over from this machine called machine_a. It was supposed to be named machine_c. And it is when you log in...however when I'm in the ILO console before logging in, it says: It should say: What gives? And how do... (4 Replies)
Discussion started by: zixzix01
4 Replies

6. Red Hat

SEt two hostname in a linux server

Friends , Can I set two hostname in a Linux server at a time ? I want to give two hostname of my Linux server , is it possible to do ? Plz inform .. .. (2 Replies)
Discussion started by: shipon_97
2 Replies

7. Solaris

Assigning two hostname to single server

Hi All, Is there any option where in I can assign the two hostname to single system. Thanks (6 Replies)
Discussion started by: kumarmani
6 Replies

8. UNIX for Advanced & Expert Users

how do change hostname of a unix server

what command do you use to change a unix server name. i've tried hostname, but when the unix server is rebooted, it reverts back to the old server name. regards venhart (3 Replies)
Discussion started by: venhart
3 Replies

9. UNIX for Dummies Questions & Answers

Solaris - unknown hostname - how can I change hostname?

Hello, I am new to Solaris. I am using stand alone Solaris 10.0 for test/study purpose and connecting to internet via an ADSL modem which has DHCP server. My Solaris is working on VMWare within winXP. My WinXP and Solaris connects to internet by the same ADSL modem via its DHCP at the same... (1 Reply)
Discussion started by: XNOR
1 Replies

10. IP Networking

looking up hostname

Using Solaris 8 (or WINXP). I am trying to look up a specific DNS hostname, but I don't know which DNS server houses that entry. How can I find the hostname? nslookup gives me the following: C:\>nslookup hostname Server: dnsserver Address: x.x.x.x *** dnsserver can't find hostname:... (2 Replies)
Discussion started by: dangral
2 Replies
Login or Register to Ask a Question