Duplicate Line Finder

[problem]

Have you ever duplicated a cron entry, or just wanted to find duplicate lines in a file.

[/problem]

[solution]

Here is a simple one liner, which shows all lines which occur more than once in a file or standard output.

[/solution]

[example]


sort cronfile.223 | uniq -c | awk ' $1 != 1 '

So to check that cron directly – just do this:


crontab -l | uniq -c | awk ' $1 != 1 '

[/example]

[reference]

[tags]UNIX, awk, script, uniq, Unix Coding School[/tags]

[/reference]

Legato Networker Restore

[problem]

You want to perform a restore from a legato networker backup server.
Also called NSR backup system

[/problem]

[solution]

To restore from an NSR (networker) backup system, just run recover.

It is best if you cd into the required directory first.

[/solution]

[example]


cd /var/www/httpd
recover

It will list your last back ups with dir. You can type help for more info.

Or just add, then when done – type recover.

dir shows if the tape containing your backup, is online or not.

[/example]

[reference]

[tags]NSR, Netwoker, Net backup, Legato, Unix Coding School[/tags]

[/reference]

mysql API socket connection

[problem]

Sometimes you need to connect to mysql server with a UNIX socket, rather than a Port.

Generally this is when running multiple versions, on a box when you do not want to
or cannot connect to multiple ports.

[/problem]

[solution]

If you want to connect to the mysql server from the command line, you can use -S.

Or within Perl – append mysql_socket to the dsn

[/solution]

[example]


mysql -uUSER -pPASSWORD -S /tmp/mysql.sock


dbi:mysql:database=database_name;mysql_socket=/tmp/mysql.sock

Where your socket is /tmp/mysql.sock

[/example]

[reference]

[tags]MySQL, Socket, UNIX, Perl, Perl Coding School[/tags]

[/reference]

Check NSR Legato Networker Backups

[problem]

You want to view the back ups performed via Legato Networker NSR.

[/problem]

[solution]

Use mminfo – media manager for NSR. It can show which filesystems were backed up,
when they were backed up, to which tapes and the retension period.

[/solution]

[example]


mminfo -ot -s SERVER -c CLIENT -q 'savetime>=last week' -r 'volume,client,savetime(18),ssid,name,written,pool'


mminfo -ot -s SERVER -c CLIENT -q 'savetime>=last week' -r 'volume,client,savetime(18),ssid,name,written,pool,ssretent'

[/example]

[reference]

For more information on available options, do a man mminfo

[tags]NSR, Backups, Legato, mminfo, Unix Coding School[/tags]

[/reference]

RISC System 6000 Boot LEDs

[problem]

Your RS6000 ain’t booting. 🙂 Or you are just interested what the LEDs mean.

[/problem]

[solution]

See Example

[/solution]

[example]

  1. Power On [LED 100 – 199]
  2. BIST [LED 100 – 199]
  3. POST [LED 201 – 298]
  4. Load Kernel [LED 299]
  5. Configuration [LED 500 – 999]
  6. INIT [LED 553]

init than loads /etc/inittab services – then /sbin/rc.boot (phase 3 of system boot),
/etc/rc (startup shell script), subsystems (cron, qdaemon, tcpip), getty (enable terminals)

[/example]

[reference]

[tags]RISC System bootup LEDs, AIX startup sequence, Unix Coding School[/tags]

[/reference]

Clearing an AIX Print Queue

[problem]

You have jobs stuck in the print queue. You want to clear the queues and remove all jobs.

[/problem]

[solution]

You have to stop all processes and remove the files from spooling directories.

Probably worth taking a backup of these files first. 🙂 All at own risk.

[/solution]

[example]

1.


stopsrc -cs qdaemon # bring down qdaemon and clear qdforks.
stopsrc -s lpd

2.


rm /etc/qconfig.bin # compiled /etc/qconfig

3.


rm /var/spool/lpd/qdir/* # queue requests; JDF

4.


rm /var/spool/lpd/stat/* # info on status of devices

5.


rm /var/spool/lpd/pio/msg* # error message files.

6.


rm /var/spool/qdaemon # temp copies of queue jobs

7.


rm /var/spool/lpd/* # temp copies of remote jobs

8.


ps -ef | grep pio # kill any of these processes; look for piobe, pioformat, pioout

9.


ps -ef | grep qd # kill any of these processes; look for qdforks.

10.


startsrc -s qdaemon # restarting qdaemon
startsrc -s lpd # restarting lpd

11.


lssrc -s qdaemon #look for active
ps -ef | grep qdaemon
lssrc -s lpd # look for active
ps -ef | grep lpd

12.


ps -ef | grep srcmstr # if there are 2 running, kill -9 one of them with higher PID.

13.

As a last resort – reboot

[/example]

[reference]

[tags], Unix Coding School[/tags]

[/reference]

DNS, Sendmail and Building Linux

[problem]

Have been aware of DNS and sendmail for over 10 years, but never really dabbled.

[/problem]

[solution]

Hit a lot of issues, mainly with dodgy clients – like outlook (ended up moving over completely to mozilla’s thunderbird email client!). Also with port forwarding and firewall, default routes, etc.

To set it all up these were my steps:

1) Build RH Linux server with fedora core 4 (5 is out now too I think).
2) Ensure BIND was installed. yum is your friend! 🙂 Do yum –help as root.
3) Edit /etc/named.conf – add my zone file. Always make a bu: cp -i /etc/named.conf /etc/named.conf.$(date +%j)
4) Copied localdomain.zone to puterpet.zone # this domain is retired now. 🙂
5) Modified puterpet.zone to include my info: SOA (start of authority) – in my case I said zion.puterpet.com as this then relates to the ip of broadband router. Bit backward in logic, specify your DNS server with a name registered in your DNS server! 🙂 Then I created an A record and NS for zion; CNAME for www to zion and CNAME for mail; lastly an MX record for mail. I’ll happily supply my zone file if someone wants a peek. 🙂
6) Register domain name with www.domaincentral.com.au – $12.50 a year! 🙂 Give it the ip of my DNS server – which is actually the broadband router, with port 53 forwarded to my RH Linux box. domaincentral have been great (I’ve now got 3 domains with them). www.puterpet.com – this one www.techie-blogs.com and darlingranges.com (still setting this up).
7) Setup port forwarding on broadband router, then fire up named and it was all good. Setup up virtual hosts (www.puterpet.com and mail.puterpet.com) in that domain. Now can setup any mail account or host in that domain, it is just beautiful! 🙂
8) Installed/updated sendmail. Especially like watching sendmail’s incoming and outgoing messages. 🙂
9) Edit /etc/mail/sendmail.mc – which is a macro config file that gets fed into m4 (macro language). Had to update m4, etc as kept breaking during conversion.
10) Edited various other files under /etc/mail – such as relay_domains (allow email from puterpet.com, etc); aliases …
12) Installed dovecot – which services POP and SMTP requests.
13) Created some accounts to handle mail – sales; enquiries, etc.
14) Modified my apache confs to handle and redirectmatch to new domain.

[/solution]

[example]

[/example]

[reference]

[tags]sendmail, DNS, POP, SMTP, Red Hat Linux, Unix Coding School[/tags]

[/reference]