Archive for the 'Scripts' Category

Consistent MySQL backups using ZFS snapshots

It should come as no surprise to readers of this blog that I really like ZFS. Personally I think it is one of the biggest developments in file system design in many many years. One place where I’ve started to use it recently on my own home server is to make instant and consistent backups […]

Use pfiles to peek into your application

Have you ever asked yourself what files a specific application is accessing at the moment? If the answer is yes and you are running Solaris then pfiles(1) is the answer.
First you need to find the PID of the application that you are interested in. In this example will we look at syslog.

# ps -ef […]

Clone your ZFS root file system with one easy command

In their latest release Nexenta added support for ZFS boot. I also wrote an article about how to clone and boot another ZFS file system. The process is quite simple but it still contains a number of steps.
To make things even easier I decided to write a script to automate the process. This can be […]

Better Scripts #3 - use logger

When you write scripts, especially scripts that will be executed unattended by cron or a similar facility, in most cases you want some way of getting error messages. Sometimes email is the way to go, sometimes you can just redirect output to a text file. Solaris and most other *NIX operating systems are shipped with […]

How to detect hardware problems in Solaris 10

There was many great new features included in Solaris 10, including SMF that I blogged about earlier on how to utilize it to detect problems. Another wonderful tool is the Solaris Fault Management. It is part of the Self Healing technologies available in Solaris 10. It monitors your system and if it detects errors it […]

How to use SMF to quickly detect problems

SMF (Service Management Facility) was introduced in Solaris 10 and it radically changed how you work with services. Gone are the old SysV scripts but they still work and not all services that are shipped with Solaris 10 is converted yet. If you have been a UNIX admin for a while they will feel foreign […]

Scrub your zfs file systems regularly

One of many great features introduced with Solaris 10 zfs is probably one of the greatest. Once you have learned to use it you will be thinking why it took so long for someone to figure it out.
zfs provides you with end-to-end checksums of all data stored in the filesystem. It also provides you with […]

How to capture your session

If you are doing a very sensitive operation on a server and you want to make sure that you can easily review your actions (and the result) afterwards you have two options:

Rely on the scrollback in your terminal. More often than not you will run out of scrollback
Use script

When you run script it will start […]

Using at to schedule scripts

If you have some basic knowledge of UNIX you probably know about cron. But have you heard about at?
at is very similar to cron. You use it to schedule to run a program/script/command once at a specific time. A very basic example would look like this

$ at now
> date >/var/tmp/date.output
> ^D
job 1 at Mon Jun […]

Better Scripts #2 - Don’t use bash

If you want to cause a controversy on mailing lists go ahead and ask a question about which shell you should use. There are a million different opinions about this even though there is not that many shells available.
However, when you want to write portable scripts please don’t use bash but use ksh (or even […]