How to enable NTP on Solaris 10
online 13:35:01 svc:/network/ntp:default
[root@server# ps -ef|grep ntp
root 1459 1188 0 13:37:23 console 0:00 grep ntp
root 1393 1 0 13:35:01 ? 0:00 /usr/lib/inet/xntpd
online 13:35:01 svc:/network/ntp:default
[root@server# ps -ef|grep ntp
root 1459 1188 0 13:37:23 console 0:00 grep ntp
root 1393 1 0 13:35:01 ? 0:00 /usr/lib/inet/xntpd
Below is a script that I put together to log into multipliable machines via ssh to grab the uptime of the machine. In this situation the machines are all Solaris of either 8,9,10. There is no reason that this script or any other script that I write can not be used on linux or any other *NIX with out a tiny bit of modification. I try to put plenty of comments into my scripts so they are easy to understand.
#!/bin/sh
# Written By: BAB
#Purpose: To gather the uptime from Unix machiens and present it in a readable fashion in order of uptime
#This is to be run from one central machine becuase that is where the ssh keys are set up from
#Prerequisites: ssh, sort, echo, nawk
#Files Used:uptime-before, and uptime-sorted. uptime-before is where all the machine names and uptime is stored before they are sorted and up in uptime-sorted
#Example Output: machine_name uptime, each on new line starting with shortest uptime, machines with <24 hours can show up not in their proper location because 17 hours is greater then 12 days!DATE=`/usr/bin/date`
echo “” > uptime-before
echo “Starting to gather uptime”
#add additional files with machine names to the end of the cat command below. The files should have one machine name (host name translatable via DNS) per a line
for server in `cat /opt/scripts/sudo/sudoserver_list /opt/scripts/sudo/stagingserver_list /opt/scripts/sudo/non_sudo_server`
do
uptime=`ssh root@$server uptime | nawk ‘{print $3}’ `echo “$server $uptime” >> uptime-before
done
echo “done getting uptime”echo “$DATE” > uptime-sorted
sort -u uptime-before | sort +1 -n >> uptime-sortedmailx -s “Weekly uptime report” manager@company.com < /opt/scripts/uptime-sorted
Below is a script that I wrote to back up a bunch of files, tar them and then compress them. Why use two different programs, tar and zip, because it is the UNIX way. Use one specialty program to do one thing, and one thing very well. If you put too many features into your UNIX programs then they just grow too monstrous and unmanageable like Windows (just a example).
#!/bin/bash#Written By: BAB
#The purpose of this script is to back up all directories listed, compress the directories, encript the directories, and send them to a remote site.
#compressioin /bin/bzip2
#archiving /bin/tar
#encription /usr/bin/gpg
ZIP=/bin/bzip2
TAR=/bin/tar
ENCRYPT=/usr/bin/gpg
RM=/usr/bin/rm
DATE=`/usr/bin/date +%m/%d/%Y`BACKUPDIRS=/home/one /home/two
BACKUPNAME=server-backup$DATE
REMOTESERVER=server.comREMOTEUSERNAME=username
GPGNAME=my name
echo “starting backup”
echo ” AKA tar”
$TAR -cf $BACKUPNAME.tar $BACKUPDIRS
echo “Starting zip”
$ZIP -z $BACKUPNAME.tarecho “starting encryption”
$ENCRYPT –encrypt –recipient ‘$GPGNAME’ BACKUPNAME.tarecho “sending to remote site one”
scp FILE $REMOTEUSERNAME@REMOTESERVER:~echo “doing cleanup”
$RM $BACKUPNAME.tar.gpg
echo “cleanup done”echo “Backup Complete!”
#echo “Decripting the file”
#gpg –output foo.txt –decrypt foo.txt.gpg# echo “Usage: $0 {-encript -decript}” >&2
# exit 1
# ;;
#esac#exit 0
Or use the script below to that a whole bunch of machines to make sure remote sysloging is working.
#!/bin/sh
# Written By: BAB
#Purpose: to make sure syslog is working properlyecho “starting to test syslog”
for server in `cat /opt/scripts/machine list` # file with only one machine per a line resoveable via DNS
do
ssh root@$server logger -p local3.alert “Hello World”
echo “done testing syslog”
done
So if you don’t see the machine’s name in your syslog file then there is something wrong.
vxedit -g sydata set user= group= mode= NameRawPart